Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Underline #6277

Merged
merged 6 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ source-repository-package

source-repository-package
type: git
location: https://github.com/vaibhavsagar/pandoc-types
tag: 4503ff82862270e07e0ba7c2a3c68c31f31d51f7
location: https://github.com/jgm/pandoc-types
tag: dd50a6eaeaf63773bbf04d6ef34b86d6f92b7825
2 changes: 1 addition & 1 deletion src/Text/Pandoc/Readers/Docx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ runStyleToTransform rPr
return $ subscript . transform
| Just "single" <- rUnderline rPr = do
transform <- runStyleToTransform rPr{rUnderline = Nothing}
return $ underlineSpan . transform
return $ Pandoc.underline . transform
| otherwise = return id

runToInlines :: PandocMonad m => Run -> DocxContext m Inlines
Expand Down
4 changes: 2 additions & 2 deletions src/Text/Pandoc/Readers/DokuWiki.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Text.Pandoc.Definition
import Text.Pandoc.Error (PandocError (PandocParsecError))
import Text.Pandoc.Options
import Text.Pandoc.Parsing hiding (enclosed, nested)
import Text.Pandoc.Shared (crFilter, trim, underlineSpan, stringify, tshow)
import Text.Pandoc.Shared (crFilter, trim, stringify, tshow)

-- | Read DokuWiki from an input string and return a Pandoc document.
readDokuWiki :: PandocMonad m
Expand Down Expand Up @@ -162,7 +162,7 @@ italic :: PandocMonad m => DWParser m B.Inlines
italic = try $ B.emph <$> enclosed (string "//") nestedInlines

underlined :: PandocMonad m => DWParser m B.Inlines
underlined = try $ underlineSpan <$> enclosed (string "__") nestedInlines
underlined = try $ B.underline <$> enclosed (string "__") nestedInlines

nowiki :: PandocMonad m => DWParser m B.Inlines
nowiki = try $ B.text <$ string "<nowiki>" <*> manyTillChar anyChar (try $ string "</nowiki>")
Expand Down
4 changes: 2 additions & 2 deletions src/Text/Pandoc/Readers/HTML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import Text.Pandoc.Options (
import Text.Pandoc.Parsing hiding ((<|>))
import Text.Pandoc.Shared (addMetaField, blocksToInlines', crFilter, escapeURI,
extractSpaces, htmlSpanLikeElements, elemText, splitTextBy,
onlySimpleTableCells, safeRead, underlineSpan, tshow)
onlySimpleTableCells, safeRead, tshow)
import Text.Pandoc.Walk
import Text.Parsec.Error
import Text.TeXMath (readMathML, writeTeX)
Expand Down Expand Up @@ -749,7 +749,7 @@ pStrikeout =
return $ B.strikeout contents)

pUnderline :: PandocMonad m => TagParser m Inlines
pUnderline = pInlinesInTags "u" underlineSpan <|> pInlinesInTags "ins" underlineSpan
pUnderline = pInlinesInTags "u" B.underline <|> pInlinesInTags "ins" B.underline

pLineBreak :: PandocMonad m => TagParser m Inlines
pLineBreak = do
Expand Down
4 changes: 2 additions & 2 deletions src/Text/Pandoc/Readers/JATS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Text.HTML.TagSoup.Entity (lookupEntity)
import Text.Pandoc.Builder
import Text.Pandoc.Class.PandocMonad (PandocMonad)
import Text.Pandoc.Options
import Text.Pandoc.Shared (underlineSpan, crFilter, safeRead)
import Text.Pandoc.Shared (crFilter, safeRead)
import Text.TeXMath (readMathML, writeTeX)
import Text.XML.Light
import qualified Data.Set as S (fromList, member)
Expand Down Expand Up @@ -456,7 +456,7 @@ parseInline (Elem e) =
"strike" -> strikeout <$> innerInlines
"sub" -> subscript <$> innerInlines
"sup" -> superscript <$> innerInlines
"underline" -> underlineSpan <$> innerInlines
"underline" -> underline <$> innerInlines
"break" -> return linebreak
"sc" -> smallcaps <$> innerInlines

Expand Down
6 changes: 3 additions & 3 deletions src/Text/Pandoc/Readers/LaTeX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
, ("slash", lit "/")
, ("textbf", extractSpaces strong <$> tok)
, ("textnormal", extractSpaces (spanWith ("",["nodecor"],[])) <$> tok)
, ("underline", underlineSpan <$> tok)
, ("underline", underline <$> tok)
, ("ldots", lit "…")
, ("vdots", lit "\8942")
, ("dots", lit "…")
Expand Down Expand Up @@ -1171,9 +1171,9 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
-- include
, ("input", rawInlineOr "input" $ include "input")
-- soul package
, ("ul", underlineSpan <$> tok)
, ("ul", underline <$> tok)
-- ulem package
, ("uline", underlineSpan <$> tok)
, ("uline", underline <$> tok)
-- plain tex stuff that should just be passed through as raw tex
, ("ifdim", ifdim)
]
Expand Down
6 changes: 3 additions & 3 deletions src/Text/Pandoc/Readers/Muse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ import qualified Data.Set as Set
import Data.Maybe (fromMaybe, isNothing, maybeToList)
import Data.Text (Text)
import qualified Data.Text as T
import Text.Pandoc.Builder (Blocks, Inlines)
import Text.Pandoc.Builder (Blocks, Inlines, underline)
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class.PandocMonad (PandocMonad (..))
import Text.Pandoc.Definition
import Text.Pandoc.Error (PandocError (PandocParsecError))
import Text.Pandoc.Logging
import Text.Pandoc.Options
import Text.Pandoc.Parsing hiding (F)
import Text.Pandoc.Shared (crFilter, trimr, underlineSpan, tshow)
import Text.Pandoc.Shared (crFilter, trimr, tshow)

-- | Read Muse from an input string and return a Pandoc document.
readMuse :: PandocMonad m
Expand Down Expand Up @@ -849,7 +849,7 @@ emph = fmap B.emph <$> emphasisBetween (char '*' <* notFollowedBy (char '*'))
-- | Parse underline inline markup, indicated by @_@.
-- Supported only in Emacs Muse mode, not Text::Amuse.
underlined :: PandocMonad m => MuseParser m (F Inlines)
underlined = fmap underlineSpan
underlined = fmap underline
<$ guardDisabled Ext_amuse -- Supported only by Emacs Muse
<*> emphasisBetween (char '_')

Expand Down
3 changes: 1 addition & 2 deletions src/Text/Pandoc/Readers/Org/Inlines.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import Text.Pandoc.Class.PandocMonad (PandocMonad)
import Text.Pandoc.Definition
import Text.Pandoc.Options
import Text.Pandoc.Readers.LaTeX (inlineCommand, rawLaTeXInline)
import Text.Pandoc.Shared (underlineSpan)
import Text.TeXMath (DisplayType (..), readTeX, writePandoc)
import qualified Text.TeXMath.Readers.MathML.EntityMap as MathMLEntityMap

Expand Down Expand Up @@ -567,7 +566,7 @@ strikeout :: PandocMonad m => OrgParser m (F Inlines)
strikeout = fmap B.strikeout <$> emphasisBetween '+'

underline :: PandocMonad m => OrgParser m (F Inlines)
underline = fmap underlineSpan <$> emphasisBetween '_'
underline = fmap B.underline <$> emphasisBetween '_'

verbatim :: PandocMonad m => OrgParser m (F Inlines)
verbatim = return . B.code <$> verbatimBetween '='
Expand Down
4 changes: 2 additions & 2 deletions src/Text/Pandoc/Readers/Textile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import Text.Pandoc.Options
import Text.Pandoc.Parsing
import Text.Pandoc.Readers.HTML (htmlTag, isBlockTag, isInlineTag)
import Text.Pandoc.Readers.LaTeX (rawLaTeXBlock, rawLaTeXInline)
import Text.Pandoc.Shared (crFilter, trim, underlineSpan, tshow)
import Text.Pandoc.Shared (crFilter, trim, tshow)

-- | Parse a Textile text and return a Pandoc document.
readTextile :: PandocMonad m
Expand Down Expand Up @@ -451,7 +451,7 @@ inlineMarkup = choice [ simpleInline (string "??") (B.cite [])
, simpleInline (string "__") B.emph
, simpleInline (char '*') B.strong
, simpleInline (char '_') B.emph
, simpleInline (char '+') underlineSpan
, simpleInline (char '+') B.underline
, simpleInline (char '-' <* notFollowedBy (char '-')) B.strikeout
, simpleInline (char '^') B.superscript
, simpleInline (char '~') B.subscript
Expand Down
5 changes: 2 additions & 3 deletions src/Text/Pandoc/Readers/Txt2Tags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ import Data.Time (defaultTimeLocale)
import Text.Pandoc.Definition
import Text.Pandoc.Options
import Text.Pandoc.Parsing hiding (space, spaces, uri)
import Text.Pandoc.Shared (compactify, compactifyDL, crFilter, escapeURI,
underlineSpan)
import Text.Pandoc.Shared (compactify, compactifyDL, crFilter, escapeURI)

type T2T = ParserT Text ParserState (Reader T2TMeta)

Expand Down Expand Up @@ -378,7 +377,7 @@ bold :: T2T Inlines
bold = inlineMarkup inline B.strong '*' B.str

underline :: T2T Inlines
underline = inlineMarkup inline underlineSpan '_' B.str
underline = inlineMarkup inline B.underline '_' B.str

strike :: T2T Inlines
strike = inlineMarkup inline B.strikeout '-' B.str
Expand Down
2 changes: 1 addition & 1 deletion src/Text/Pandoc/Shared.hs
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ eastAsianLineBreakFilter = bottomUp go
go xs
= xs

-- | Builder for underline.
-- | Builder for underline (deprecated).
vaibhavsagar marked this conversation as resolved.
Show resolved Hide resolved
-- This probably belongs in Builder.hs in pandoc-types.
-- Will be replaced once Underline is an element.
underlineSpan :: Inlines -> Inlines
Expand Down
4 changes: 2 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ packages:
extra-deps:
# - pandoc-types-1.20
# better-tables
- git: https://github.com/vaibhavsagar/pandoc-types
commit: 4503ff82862270e07e0ba7c2a3c68c31f31d51f7
- git: https://github.com/jgm/pandoc-types
commit: dd50a6eaeaf63773bbf04d6ef34b86d6f92b7825
- git: https://github.com/jgm/pandoc-citeproc
commit: 2e6fe791ec5293acc925c2ccbe79c9c10d2b7e07
- texmath-0.12.0.2
Expand Down
5 changes: 2 additions & 3 deletions test/Tests/Readers/DokuWiki.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import Tests.Helpers
import Text.Pandoc
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
import Text.Pandoc.Shared (underlineSpan)

dokuwiki :: Text -> Pandoc
dokuwiki = purely $ readDokuWiki def{ readerStandalone = True }
Expand All @@ -42,7 +41,7 @@ tests = [ testGroup "inlines"
para (emph "italic")
, "Underlined" =:
"__underlined__" =?>
para (underlineSpan "underlined")
para (underline "underlined")
, "Monospaced" =:
"''monospaced''" =?>
para (code "monospaced")
Expand All @@ -51,7 +50,7 @@ tests = [ testGroup "inlines"
para (code "monospaced")
, "Combined" =:
"**__//''combine''//__**" =?>
para (strong $ underlineSpan $ emph $ code "combine")
para (strong $ underline $ emph $ code "combine")
, "Nowiki" =:
T.unlines [ "<nowiki>"
, "This is some text which contains addresses like this: http://www.splitbrain.org and **formatting**, but nothing is done with it."
Expand Down
3 changes: 1 addition & 2 deletions test/Tests/Readers/Muse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import Tests.Helpers
import Text.Pandoc
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
import Text.Pandoc.Shared (underlineSpan)
import Text.Pandoc.Writers.Shared (toLegacyTable)
import Text.Pandoc.Walk

Expand Down Expand Up @@ -209,7 +208,7 @@ tests =
para (strong . emph $ "foo******bar")

, test emacsMuse "Underline"
("_Underline_" =?> para (underlineSpan "Underline"))
("_Underline_" =?> para (underline "Underline"))

, "Superscript tag" =: "<sup>Superscript</sup>" =?> para (superscript "Superscript")

Expand Down
3 changes: 1 addition & 2 deletions test/Tests/Readers/Org/Inline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Test.Tasty (TestTree, testGroup)
import Tests.Helpers ((=?>))
import Tests.Readers.Org.Shared ((=:), spcSep)
import Text.Pandoc.Builder
import Text.Pandoc.Shared (underlineSpan)
import qualified Data.Text as T
import qualified Tests.Readers.Org.Inline.Citation as Citation
import qualified Tests.Readers.Org.Inline.Note as Note
Expand Down Expand Up @@ -49,7 +48,7 @@ tests =

, "Underline" =:
"_underline_" =?>
para (underlineSpan "underline")
para (underline "underline")

, "Strikeout" =:
"+Kill Bill+" =?>
Expand Down
5 changes: 2 additions & 3 deletions test/Tests/Readers/Txt2Tags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Tests.Helpers
import Text.Pandoc
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
import Text.Pandoc.Shared (underlineSpan)

t2t :: Text -> Pandoc
-- t2t = handleError . readTxt2Tags (T2TMeta "date" "mtime" "in" "out") def
Expand Down Expand Up @@ -94,12 +93,12 @@ tests =

, "Inline markup is greedy" =:
"***** ///// _____ ----- ````` \"\"\"\"\" '''''" =?>
para (spcSep [strong "*", emph "/", underlineSpan "_"
para (spcSep [strong "*", emph "/", underline "_"
, strikeout "-", code "`", text "\""
, rawInline "html" "'"])
, "Markup must be greedy" =:
"********** ////////// __________ ---------- `````````` \"\"\"\"\"\"\"\"\"\" ''''''''''" =?>
para (spcSep [strong "******", emph "//////", underlineSpan "______"
para (spcSep [strong "******", emph "//////", underline "______"
, strikeout "------", code "``````", text "\"\"\"\"\"\""
, rawInline "html" "''''''"])
, "Inlines must be glued" =:
Expand Down