git.iko.soy/typeable/pandoc
on master help sign in
Textile reader: don't do smart punctuation unless explicitly asked.

Closes #2480. Note that although smart punctuation is part of the textile spec, it's not always wanted when converting from textile to, say, Markdown. So it seems better to make this an option.

commit532ae22c290b40932c1797b19b9cb4248ec543f6 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 30 Oct 2015, 10:50 (11 years ago) parentd1ba023
3 files changed+14−15
README+2−4 src/Text/Pandoc/Readers/Textile.hs+4−3 tests/textile-reader.native+8−8
README+2−4
@@ -372,10 +372,8 @@ Reader options
372372: Produce typographically correct output, converting straight quotes
373373 to curly quotes, `---` to em-dashes, `--` to en-dashes, and
374374 `...` to ellipses. Nonbreaking spaces are inserted after certain
375− abbreviations, such as "Mr." (Note: This option is significant only when
376− the input format is `markdown`, `markdown_strict`, `textile` or `twiki`.
377− It is selected automatically when the input format is `textile` or the
378− output format is `latex` or `context`, unless `--no-tex-ligatures`
375+ abbreviations, such as "Mr." (Note: This option is selected automatically
376+ when the output format is `latex` or `context`, unless `--no-tex-ligatures`
379377 is used.)
380378
381379`--old-dashes`
src/Text/Pandoc/Readers/Textile.hs+4−3
@@ -79,11 +79,12 @@ readTextile opts s =
7979-- | Generate a Pandoc ADT from a textile document
8080parseTextile :: Parser [Char] ParserState Pandoc
8181parseTextile = do
82− -- textile allows raw HTML and does smart punctuation by default
82+ -- textile allows raw HTML and does smart punctuation by default,
83+ -- but we do not enable smart punctuation unless it is explicitly
84+ -- asked for, for better conversion to other light markup formats
8385 oldOpts <- stateOptions `fmap` getState
8486 updateState $ \state -> state{ stateOptions =
85− oldOpts{ readerSmart = True
86− , readerParseRaw = True
87+ oldOpts{ readerParseRaw = True
8788 , readerOldDashes = True
8889 } }
8990 many blankline
tests/textile-reader.native+8−8
@@ -1,5 +1,5 @@
11Pandoc (Meta {unMeta = fromList []})
2−[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Space,Str "Textile",Space,Str "Reader.",Space,Str "Part",Space,Str "of",Space,Str "it",Space,Str "comes",LineBreak,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
2+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Space,Str "Textile",Space,Str "Reader.",Space,Str "Part",Space,Str "of",Space,Str "it",Space,Str "comes",LineBreak,Str "from",Space,Str "John",Space,Str "Gruber's",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
33,HorizontalRule
44,Header 1 ("headers",[],[]) [Str "Headers"]
55,Header 2 ("level-2-with-an-embeded-link",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embeded",Space,Str "link"] ("http://www.example.com","")]
@@ -8,9 +8,9 @@ Pandoc (Meta {unMeta = fromList []})
88,Header 5 ("level-5",[],[]) [Str "Level",Space,Str "5"]
99,Header 6 ("level-6",[],[]) [Str "Level",Space,Str "6"]
1010,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]
11−,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
11+,Para [Str "Here's",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
1212,Para [Str "Line",Space,Str "breaks",Space,Str "are",Space,Str "preserved",Space,Str "in",Space,Str "textile,",Space,Str "so",Space,Str "you",Space,Str "can",Space,Str "not",Space,Str "wrap",Space,Str "your",Space,Str "very",LineBreak,Str "long",Space,Str "paragraph",Space,Str "with",Space,Str "your",Space,Str "favourite",Space,Str "text",Space,Str "editor",Space,Str "and",Space,Str "have",Space,Str "it",Space,Str "rendered",LineBreak,Str "with",Space,Str "no",Space,Str "break."]
13−,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet."]
13+,Para [Str "Here's",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet."]
1414,BulletList
1515 [[Plain [Str "criminey."]]]
1616,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "paragraph",Space,Str "break",Space,Str "between",Space,Str "here"]
@@ -87,9 +87,9 @@ Pandoc (Meta {unMeta = fromList []})
8787,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str ".",LineBreak,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str ".",LineBreak,Str "Hyphenated-words-are-ok,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "strange_underscore_notation.",LineBreak,Str "A",Space,Link [Strong [Str "strong",Space,Str "link"]] ("http://www.foobar.com",""),Str "."]
8888,Para [Emph [Strong [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]],LineBreak,Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Space,Str "and",Space,Emph [Strong [Str "that",Space,Str "one"]],Str ".",LineBreak,Strikeout [Str "This",Space,Str "is",Space,Str "strikeout",Space,Str "and",Space,Strong [Str "strong"]]]
8989,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Space,Superscript [Strong [Str "hello"]],Space,Str "a",Superscript [Str "hello",Space,Str "there"],Str ".",LineBreak,Str "Subscripts:",Space,Subscript [Str "here"],Space,Str "H",Space,Subscript [Str "2"],Str "O,",Space,Str "H",Space,Subscript [Str "23"],Str "O,",Space,Str "H",Space,Subscript [Str "many",Space,Str "of",Space,Str "them"],Str "O."]
90−,Para [Str "Dashes",Space,Str ":",Space,Str "How",Space,Str "cool",Space,Str "\8212",Space,Str "automatic",Space,Str "dashes."]
91−,Para [Str "Elipses",Space,Str ":",Space,Str "He",Space,Str "thought",Space,Str "and",Space,Str "thought",Space,Str "\8230",Space,Str "and",Space,Str "then",Space,Str "thought",Space,Str "some",Space,Str "more."]
92−,Para [Str "Quotes",Space,Str "and",Space,Str "apostrophes",Space,Str ":",Space,Quoted DoubleQuote [Str "I\8217d",Space,Str "like",Space,Str "to",Space,Str "thank",Space,Str "you"],Space,Str "for",Space,Str "example."]
90+,Para [Str "Dashes",Space,Str ":",Space,Str "How",Space,Str "cool",Space,Str "--",Space,Str "automatic",Space,Str "dashes."]
91+,Para [Str "Elipses",Space,Str ":",Space,Str "He",Space,Str "thought",Space,Str "and",Space,Str "thought",Space,Str "...",Space,Str "and",Space,Str "then",Space,Str "thought",Space,Str "some",Space,Str "more."]
92+,Para [Str "Quotes",Space,Str "and",Space,Str "apostrophes",Space,Str ":",Space,Str "\"I'd",Space,Str "like",Space,Str "to",Space,Str "thank",Space,Str "you\"",Space,Str "for",Space,Str "example."]
9393,Header 1 ("links",[],[]) [Str "Links"]
9494,Header 2 ("explicit",[],[]) [Str "Explicit"]
9595,Para [Str "Just",Space,Str "a",Space,Link [Str "url"] ("http://www.url.com","")]
@@ -114,7 +114,7 @@ Pandoc (Meta {unMeta = fromList []})
114114 ,[[Plain [Str "bella"]]
115115 ,[Plain [Str "45"]]
116116 ,[Plain [Str "f"]]]]
117−,Para [Str "and",Space,Str "some",Space,Str "text",Space,Str "following",Space,Str "\8230"]
117+,Para [Str "and",Space,Str "some",Space,Str "text",Space,Str "following",Space,Str "..."]
118118,Header 2 ("with-headers",[],[]) [Str "With",Space,Str "headers"]
119119,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
120120 [[Plain [Str "name"]]
@@ -152,7 +152,7 @@ Pandoc (Meta {unMeta = fromList []})
152152,RawBlock (Format "html") "</div>"
153153,Para [Str "Html",Space,Str "blocks",Space,Str "can",Space,Str "be",Space,RawInline (Format "html") "<div>",Str "inlined",RawInline (Format "html") "</div>",Space,Str "as",Space,Str "well."]
154154,BulletList
155− [[Plain [Str "this",Space,RawInline (Format "html") "<div>",Space,Str "won\8217t",Space,Str "produce",Space,Str "raw",Space,Str "html",Space,Str "blocks",Space,RawInline (Format "html") "</div>"]]
155+ [[Plain [Str "this",Space,RawInline (Format "html") "<div>",Space,Str "won't",Space,Str "produce",Space,Str "raw",Space,Str "html",Space,Str "blocks",Space,RawInline (Format "html") "</div>"]]
156156 ,[Plain [Str "but",Space,Str "this",Space,RawInline (Format "html") "<strong>",Space,Str "will",Space,Str "produce",Space,Str "inline",Space,Str "html",Space,RawInline (Format "html") "</strong>"]]]
157157,Para [Str "Can",Space,Str "you",Space,Str "prove",Space,Str "that",Space,Str "2",Space,Str "<",Space,Str "3",Space,Str "?"]
158158,Header 1 ("acronyms-and-marks",[],[]) [Str "Acronyms",Space,Str "and",Space,Str "marks"]