git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #2432 from hftf/hyphens
869e800John MacFarlane
src/Text/Pandoc/Readers/Docx.hs+4
@@ -206,11 +206,15 @@ runElemToInlines :: RunElem -> Inlines
206runElemToInlines (TextRun s) = text s
206runElemToInlines (TextRun s) = text s
207runElemToInlines (LnBrk) = linebreak
207runElemToInlines (LnBrk) = linebreak
208runElemToInlines (Tab) = space
208runElemToInlines (Tab) = space
209+runElemToInlines (SoftHyphen) = text "\xad"
210+runElemToInlines (NoBreakHyphen) = text "\x2011"
209
211
210runElemToString :: RunElem -> String
212runElemToString :: RunElem -> String
211runElemToString (TextRun s) = s
213runElemToString (TextRun s) = s
212runElemToString (LnBrk) = ['\n']
214runElemToString (LnBrk) = ['\n']
213runElemToString (Tab) = ['\t']
215runElemToString (Tab) = ['\t']
216+runElemToString (SoftHyphen) = ['\xad']
217+runElemToString (NoBreakHyphen) = ['\x2011']
214
218
215runToString :: Run -> String
219runToString :: Run -> String
216runToString (Run _ runElems) = concatMap runElemToString runElems
220runToString (Run _ runElems) = concatMap runElemToString runElems
src/Text/Pandoc/Readers/Docx/Parse.hs+3−1
@@ -208,7 +208,7 @@ data Run = Run RunStyle [RunElem]
208 | InlineDrawing FilePath B.ByteString
208 | InlineDrawing FilePath B.ByteString
209 deriving Show
209 deriving Show
210
210
211−data RunElem = TextRun String | LnBrk | Tab
211+data RunElem = TextRun String | LnBrk | Tab | SoftHyphen | NoBreakHyphen
212 deriving Show
212 deriving Show
213
213
214data VertAlign = BaseLn | SupScrpt | SubScrpt
214data VertAlign = BaseLn | SupScrpt | SubScrpt
@@ -877,6 +877,8 @@ elemToRunElem ns element
877 map (\x -> fromMaybe x . getUnicode f . lowerFromPrivate $ x) str
877 map (\x -> fromMaybe x . getUnicode f . lowerFromPrivate $ x) str
878 | isElem ns "w" "br" element = return LnBrk
878 | isElem ns "w" "br" element = return LnBrk
879 | isElem ns "w" "tab" element = return Tab
879 | isElem ns "w" "tab" element = return Tab
880+ | isElem ns "w" "softHyphen" element = return SoftHyphen
881+ | isElem ns "w" "noBreakHyphen" element = return NoBreakHyphen
880 | isElem ns "w" "sym" element = return (getSymChar ns element)
882 | isElem ns "w" "sym" element = return (getSymChar ns element)
881 | otherwise = throwError WrongElem
883 | otherwise = throwError WrongElem
882 where
884 where
tests/Tests/Readers/Docx.hs+4
@@ -130,6 +130,10 @@ tests = [ testGroup "inlines"
130 "literal tabs"
130 "literal tabs"
131 "docx/tabs.docx"
131 "docx/tabs.docx"
132 "docx/tabs.native"
132 "docx/tabs.native"
133+ , testCompare
134+ "special punctuation"
135+ "docx/special_punctuation.docx"
136+ "docx/special_punctuation.native"
133 , testCompare
137 , testCompare
134 "normalizing inlines"
138 "normalizing inlines"
135 "docx/normalize.docx"
139 "docx/normalize.docx"
tests/docx/special_punctuation.docxnew file

Binary file not shown.

tests/docx/special_punctuation.nativenew file+2
@@ -0,0 +1,2 @@
1+[Para [Str "Soft",Space,Str "hyphen:",Space,Str "[\173]"]
2+,Para [Str "Non-breaking",Space,Str "hyphen:",Space,Str "[\8209]"]]