Skip to content

Commit

Permalink
add docs and minimal usage
Browse files Browse the repository at this point in the history
  • Loading branch information
cscheid committed Jul 2, 2022
1 parent ce3f094 commit b0d7242
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Font Awesome extension for Quarto

This extension allows you to use [Font Awesome](https://fontawesome.com/) icons in your quarto documents.

## Installation

From the command line, at the root directory of your quarto project:

```
$ quarto install extension https://github.com/quarto-dev/quarto-ext/fontawesome
```

This will install the extension under the `_extensions` subdirectory.
If you're using version control, you will want to check in this directory.

## Usage

This extension provides the `fa` shortcode:

```
{{< fa icon-name >}}
```

For example, here's a minimal full document that uses Font Awesome icons in both PDF and HTML:

---
format:
pdf: default
html: default
---

This is a test. {{< fa book >}} {{< fa download >}}

## Known Issues

* The PDF format uses fontawesome5, while the HTML format uses fontawesome6.
* No formatting
7 changes: 0 additions & 7 deletions _extensions/quarto-ext/fontawesome/_extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@ version: 0.0.1
contributes:
shortcodes:
- shortcodes.lua
format:
pdf:
header-includes: |
\usepackage{fontawesome5}
html:
css:
assets/css/all.css
22 changes: 21 additions & 1 deletion _extensions/quarto-ext/fontawesome/shortcodes.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
function ensureLatexDeps()
quarto.doc.useLatexPackage("fontawesome5")
end

function ensureHtmlDeps()
quarto.doc.addHtmlDependency({
name = 'fontawesome6',
version = '0.1.0',
scripts = {
},
stylesheets = {
{
name = 'assets/css/all.css',
path = 'assets/css/all.css'
}
}
})
end

return {
["fa"] = function(args, kwargs)
local icon = pandoc.utils.stringify(args[1]) -- FIXME ESCAPE
Expand All @@ -6,11 +25,12 @@ return {
content = ""
return pandoc.RawBlock('openxml', "")
elseif FORMAT:match 'latex' then
-- content = "\\faicon{" .. icon .. "}"
ensureLatexDeps()
return pandoc.RawBlock('tex', "\\faIcon{" .. icon .. "}")
elseif FORMAT:match 'odt' then
return pandoc.RawBlock('opendocument', "")
elseif FORMAT:match 'html.*' then
ensureHtmlDeps()
return pandoc.RawBlock('html', "<i class=\"fa-solid fa-" .. icon .. "\"></i>")
elseif FORMAT:match 'epub' then
return pandoc.RawBlock('html', "")
Expand Down

0 comments on commit b0d7242

Please sign in to comment.