source: project/wiki/eggref/4/markdown-svnwiki @ 31694

Last change on this file since 31694 was 31694, checked in by acharlton, 7 years ago

wiki/markdown-svnwiki: Update to 0.2.0

File size: 5.2 KB
Line 
1== markdown-svnwiki
2[[toc:]]
3Converts Markdown to the svnwiki syntax used on the [[https://wiki.call-cc.org/edit-help|Chicken wiki]]. It uses [[http://wiki.call-cc.org/eggref/4/lowdown|lowdown]] to transform Markdown into SXML before transforming it into svnwiki with [[http://wiki.call-cc.org/eggref/4/sxml-transforms|sxml-transforms]]. Much credit goes to those two libraries, particularly lowdown which heavily influenced the code in markdown-svnwiki.
4
5markdown-svnwiki includes pre and post-processing phases for performing customizable transformations on the input and output. Some transformations, meant to make working with the Chicken wiki more convenient, are included by default. They are described in the section [[#special-syntax|Special Syntax]].
6
7
8=== Requirements
9* lowdown
10* sxml-transforms
11* miscmacros
12* srfi-37
13
14
15=== Usage
16markdown-svnwiki installs both a module and a command line utility. The command line utility is used as follows:
17
18    usage: markdown-svnwiki [-h | --help]
19                            [-o | --output-file NAME]
20                            [-e | --extension EXTENSION]
21                            [-t | --no-toc]
22                            [file]
23
24Convert the given Markdown file to CHICKEN's svnwiki syntax. If no file is given, stdin is read. If neither the output-file or extension arguments are given, the result is written to stdout. If the output-file argument is provided, the resulting svnwiki file is written to a file of that name. If the extension argument is given, the svnwiki file uses the same name as the input file, with the given extension.
25
26
27=== Documentation
28<procedure> (markdown->svnwiki input)</procedure>
29
30Convert the given {{input}} (may be a string or a port) into svnwiki, outputting to {{current-output-port}}.
31
32<parameter> pre-processing</parameter>
33
34An alist of functions that accept a string (the input to {{markdown->svnwiki}}) and should transform it in some way. By default contains one entry: {{code-blocks}}, for dealing with code blocks as described in Special Syntax.
35
36<parameter> post-processing</parameter>
37
38An alist of functions that accept a string (the pre-post-processed output from {{markdown->svnwiki}}) and should transform it in some way. By default contains: {{code-blocks}}, {{procedure}}, {{macro}}, {{read}}, {{parameter}}, {{record}}, {{string}}, {{class}}, {{method}}, {{constant}}, {{setter}}, {{syntax}}, and {{type}}, for dealing with code blocks and definition tags as described in Special Syntax.
39
40<parameter> toc</parameter>
41
42If true, inserts {{[[toc:]]}} after the first-level heading(s). Defaults to {{#t}}.
43
44
45==== Special syntax
46markdown-svnwiki supports the syntax highlighted code blocks that [[help.github.com/articles/github-flavored-markdown#syntax-highlighting|GitHub]], [[http://johnmacfarlane.net/pandoc/README.html#fenced-code-blocks|Pandoc]] and perhaps others support. It converts these blocks into the {{<enscript>}} tags that highlight with the given language. It does this using a pre and post-processing step, both named {{code-blocks}}. These code blocks take the following form:
47
48    ``` Scheme
49    code ...
50    ```
51
52Becomes:
53
54    <enscript highlight="scheme">
55    code ...
56    </enscript>
57
58Additionally, markdown-svnwiki supports a special syntax for adding the [[https://wiki.call-cc.org/edit-help#extensions-for-chicken-documentation|definition tags]] supported by the Chicken wiki. Single-line verbatim code blocks that begin with exactly four spaces followed by {{[definition-type]}} are given a {{<definition-type>}} tag. Only the tags supported by the Chicken wiki are supported. For example:
59
60        [procedure] (my-proc ...)
61
62Becomes:
63
64    <procedure>(my-proc ...)</procedure>
65
66
67=== Example
68This example can be compiled to make a command line program that accepts one argument - a Markdown file - and outputs a svnwiki file into the same directory. It shows the addition of of a pre-processing step - one that removes the first section called "Installation" (fairly indiscriminately, it stops at the first {{#}}).
69
70<enscript highlight="scheme">    
71(import chicken scheme irregex)
72(use markdown-svnwiki)
73
74(define file-name (cadr (argv)))
75(define output-name (pathname-replace-extension file-name "svnwiki"))
76
77(pre-processing
78 (cons
79  (cons 'remove-installation
80        (lambda (s)
81          (irregex-replace "## Installation[^#]*" s "")))
82  (pre-processing)))
83
84(call-with-output-file output-name
85  (lambda (output)
86    (call-with-input-file file-name
87      (lambda (input)
88        (current-output-port output)
89        (markdown->svnwiki input)))))
90</enscript>
91
92
93=== Version history
94
95==== Version 0.2.0
9622 October 2014
97
98* Add command line utility
99
100
101==== Version 0.1.4
10211 May 2014
103
104* Add newlines after lists
105
106'''Version 0.1.3'''
107* Improve definition post-processing to allow multiple definitions to be placed with a single new line between them
108
109'''Version 0.1.2'''
110* Fix misplaced {{@}}s in emphasis, strong
111* Accept zero whitespace before language definition of code blocks
112
113'''Version 0.1.1'''
114* Fix erroneous newline in code blocks
115
116'''Version 0.1.0'''
117* Initial release
118
119
120=== Source repository
121Source available on [[https://github.com/AlexCharlton/markdown-svnwiki|GitHub]].
122
123Bug reports and patches welcome! Bugs can be reported via GitHub or to alex.n.charlton at gmail.
124
125
126=== Author
127Alex Charlton
128
129
130=== License
131BSD
Note: See TracBrowser for help on using the repository browser.