Skip to content

Commit

Permalink
Working version
Browse files Browse the repository at this point in the history
  • Loading branch information
smutch committed Nov 16, 2022
1 parent d2ff51b commit af4fabf
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Simon Mutch

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
# Rev-history Extension For Quarto

_TODO_: Add a short description of your extension.
Generates a simple revision history table with content pulled from git tags.

## Installing

_TODO_: Replace the `<github-organization>` with your GitHub organization.

```bash
quarto add <github-organization>/rev-history
quarto add smutch/quarto-rev-history
```

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

## Using

_TODO_: Describe how to use your extension.
To tag a version of the document/project that you wish to include in the
revision table, simply ensure that your changes are commited and add a git tag.

```bash
git tag v0.0.1-alpha
```

The tag name as well as the date, author and one-line description of the
corresponding git commit will be used to populate the table.

## Example

Expand Down
13 changes: 10 additions & 3 deletions _extensions/rev-history/rev-history.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,24 @@ end
-- defining shortcodes this way allows us to create helper
-- functions that are not themselves considered shortcodes
return {
["git-rev"] = function(args, kwargs)
["rev-history"] = function(args, kwargs)
-- An example for future use (taken from quarto docs)...
-- local cmdArgs = ""
-- local short = pandoc.utils.stringify(kwargs["short"])
-- if short == "true" then cmdArgs = cmdArgs .. "--short " end

local header = "| tag | date | author | description |\n"
local divider = "|:----|:-----|:-------|:------------|\n"

-- run the command
local cmd = "for-each-ref --format='%(refname:short) | %(authordate:short) | %(authorname) | %(subject)' refs/tags"
local cmd = "for-each-ref --format='| %(refname:short) | %(authordate:short) | %(authorname) | %(subject) |' refs/tags"
local tags = git(cmd)

-- return as string
return pandoc.Str(tags)
if tags ~= nil then
return pandoc.read(header .. divider .. tags ).blocks
else
return pandoc.Null()
end
end
}
1 change: 0 additions & 1 deletion example.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ title: "Rev-history Example"

{{< rev-history >}}


0 comments on commit af4fabf

Please sign in to comment.