summary refs log tree commit diff stats
path: root/lib/packages/docutils/rstgen.nim
diff options
context:
space:
mode:
authorsingularperturbation <sloanes.k@gmail.com>2015-08-02 14:16:49 -0500
committersingularperturbation <sloanes.k@gmail.com>2015-08-02 14:16:53 -0500
commit4c1611fc13bbdc516fb08f1e12bf3a873489d705 (patch)
treedc464a9b8f17fff70c655e1e61ef2795d7731f3b /lib/packages/docutils/rstgen.nim
parentb77475bd190e6a54effeae87f1e50da516bfee20 (diff)
downloadNim-4c1611fc13bbdc516fb08f1e12bf3a873489d705.tar.gz
Fix for image directive with periods
Saw in https://github.com/nim-lang/nimforum/issues/41 that there was an
issue in rendering inline images.  Traced back through rstgen and found
that it was not counting something like:

`.. image:: http://i.imgur.com/oCem13Y.png` as valid since it contained
a period, and this wasn't in the set of valid characters, so the empty
string is returned by default.

Added a period to the allowable characters, and now renders correctly.

Test case:
```
import rst, rstgen, strtabs

var docConfig: StringTableRef

docConfig = rstgen.defaultConfig()
docConfig["doc.smiley_format"] = "/images/smilieys/$1.png"

proc rstToHtml(content: string): string =
    result = rstgen.rstToHtml(content, {roSupportSmilies,roSupportMarkdown},
                              docConfig)

var a: string = rstToHtml(".. image:: http://i.imgur.com/oCem13Y.png")
echo a
```
Diffstat (limited to 'lib/packages/docutils/rstgen.nim')
-rw-r--r--lib/packages/docutils/rstgen.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim
index cc21b9382..83e1b8b9f 100644
--- a/lib/packages/docutils/rstgen.nim
+++ b/lib/packages/docutils/rstgen.nim
@@ -755,7 +755,7 @@ proc renderTocEntries*(d: var RstGenerator, j: var int, lvl: int,
 
 proc renderImage(d: PDoc, n: PRstNode, result: var string) =
   template valid(s): expr =
-    s.len > 0 and allCharsInSet(s, {'/',':','%','_','\\','\128'..'\xFF'} +
+    s.len > 0 and allCharsInSet(s, {'.','/',':','%','_','\\','\128'..'\xFF'} +
                                    Digits + Letters + WhiteSpace)
 
   var options = ""