diff options
Diffstat (limited to 'paper/lua-filters/wordcount')
-rw-r--r-- | paper/lua-filters/wordcount/Makefile | 2 | ||||
-rw-r--r-- | paper/lua-filters/wordcount/README.md | 11 | ||||
-rw-r--r-- | paper/lua-filters/wordcount/expected.txt | 1 | ||||
-rw-r--r-- | paper/lua-filters/wordcount/sample.md | 12 | ||||
-rw-r--r-- | paper/lua-filters/wordcount/wordcount.lua | 29 |
5 files changed, 0 insertions, 55 deletions
diff --git a/paper/lua-filters/wordcount/Makefile b/paper/lua-filters/wordcount/Makefile deleted file mode 100644 index 7dfba48..0000000 --- a/paper/lua-filters/wordcount/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -test: - @pandoc --lua-filter=wordcount.lua sample.md | diff --strip-trailing-cr -u expected.txt - diff --git a/paper/lua-filters/wordcount/README.md b/paper/lua-filters/wordcount/README.md deleted file mode 100644 index 45efc2f..0000000 --- a/paper/lua-filters/wordcount/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# wordcount - -This filter counts the words in the body of a document (omitting -metadata like titles and abstracts), including words in code. -It should be more accurate than `wc -w` run directly on a -Markdown document, since the latter will count markup -characters, like the `#` in front of an ATX header, or -tags in HTML documents, as words. - -To run it, `pandoc --lua-filter wordcount.lua myfile.md`. -The word count will be printed to stdout. diff --git a/paper/lua-filters/wordcount/expected.txt b/paper/lua-filters/wordcount/expected.txt deleted file mode 100644 index dc608fc..0000000 --- a/paper/lua-filters/wordcount/expected.txt +++ /dev/null @@ -1 +0,0 @@ -15 words in body diff --git a/paper/lua-filters/wordcount/sample.md b/paper/lua-filters/wordcount/sample.md deleted file mode 100644 index 240bee0..0000000 --- a/paper/lua-filters/wordcount/sample.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: Metadata words don't count -abstract: ignored! ---- - -# Word count - -This document has *a **lot** of [words](url "title")* (15).[^1] - - code is counted - -[^1]: Footnotes count. diff --git a/paper/lua-filters/wordcount/wordcount.lua b/paper/lua-filters/wordcount/wordcount.lua deleted file mode 100644 index 19aec11..0000000 --- a/paper/lua-filters/wordcount/wordcount.lua +++ /dev/null @@ -1,29 +0,0 @@ --- counts words in a document - -words = 0 - -wordcount = { - Str = function(el) - -- we don't count a word if it's entirely punctuation: - if el.text:match("%P") then - words = words + 1 - end - end, - - Code = function(el) - _,n = el.text:gsub("%S+","") - words = words + n - end, - - CodeBlock = function(el) - _,n = el.text:gsub("%S+","") - words = words + n - end -} - -function Pandoc(el) - -- skip metadata, just count body: - pandoc.walk_block(pandoc.Div(el.blocks), wordcount) - print(words .. " words in body") - os.exit(0) -end |