diff options
-rw-r--r-- | deb/Vagrantfile | 2 | ||||
-rwxr-xr-x | deb/make_deb.sh | 18 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 13 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 14 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Textile.hs | 32 | ||||
-rw-r--r-- | stack.full.yaml | 13 | ||||
-rw-r--r-- | stack.hsb2hs.yaml | 2 | ||||
-rw-r--r-- | tests/textile-reader.native | 5 | ||||
-rw-r--r-- | tests/textile-reader.textile | 7 |
9 files changed, 66 insertions, 40 deletions
diff --git a/deb/Vagrantfile b/deb/Vagrantfile index 3a6ac14e8..182549c8c 100644 --- a/deb/Vagrantfile +++ b/deb/Vagrantfile @@ -69,7 +69,7 @@ Vagrant.configure(2) do |config| sudo apt-key add fpco.key echo 'deb http://download.fpcomplete.com/ubuntu/precise stable main'|sudo tee /etc/apt/sources.list.d/fpco.list sudo apt-get update - sudo apt-get install -y stack build-essential debhelper dh-make + sudo apt-get install -y stack build-essential debhelper dh-make curl sudo cp /vagrant_data/deb/*.pem /etc/ssl/certs/ SHELL end diff --git a/deb/make_deb.sh b/deb/make_deb.sh index fc1f1e232..f07264d78 100755 --- a/deb/make_deb.sh +++ b/deb/make_deb.sh @@ -14,28 +14,24 @@ DIST=`pwd`/$BASE DEST=$DIST/usr ME=$(whoami) COPYRIGHT=$DEST/share/doc/pandoc/copyright -TEMPDIR=make_binary_package.tmp.$$ # We need this for hsb2hs: PATH=$LOCAL/bin:$PATH -which hsb2hs || stack install --install-ghc --stack-yaml stack.hsb2hs.yaml +mkdir -p $DEST/bin +mkdir -p $DEST/share/man/man1 +mkdir -p $DEST/share/doc/pandoc +stack install --install-ghc --stack-yaml deb/stack.yaml --local-bin-path . hsb2hs stack install --install-ghc --stack-yaml deb/stack.yaml --local-bin-path . pandoc pandoc-citeproc make man/pandoc.1 # get pandoc-citeproc man page: PANDOC_CITEPROC_VERSION=`pandoc-citeproc --version | awk '{print $2;}'` -PANDOC_CITEPROC_TARBALL=https://hackage.haskell.org/package/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}.tar.gz -mkdir $TEMPDIR -curl ${PANDOC_CITEPROC_TARBALL} | tar xzC $TEMPDIR -PANDOC_CITEPROC_PATH=$TEMPDIR/pandoc-citeproc-${PANDOC_CITEPROC_VERSION} +curl https://raw.githubusercontent.com/jgm/pandoc-citeproc/${PANDOC_CITEPROC_VERSION}/man/man1/pandoc-citeproc.1 > $DEST/share/man/man1/pandoc-citeproc.1 strip deb/pandoc strip deb/pandoc-citeproc -mkdir -p $DEST/bin -mkdir -p $DEST/share/man/man1 -mkdir -p $DEST/share/doc/pandoc mkdir -p $DEST/share/doc/pandoc-citeproc find $DIST -type d | xargs chmod 755 @@ -43,13 +39,11 @@ cp deb/pandoc $DEST/bin/ cp deb/pandoc-citeproc $DEST/bin/ cp man/pandoc.1 $DEST/share/man/man1/pandoc.1 gzip -9 $DEST/share/man/man1/pandoc.1 -cp ${PANDOC_CITEPROC_PATH}/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/ gzip -9 $DEST/share/man/man1/pandoc-citeproc.1 cp COPYRIGHT $COPYRIGHT echo "" >> $COPYRIGHT echo "pandoc-citeproc" >> $COPYRIGHT -cat $PANDOC_CITEPROC_PATH/LICENSE >> $COPYRIGHT -rm -rf $TEMPDIR +curl https://raw.githubusercontent.com/jgm/pandoc-citeproc/${PANDOC_CITEPROC_VERSION}/LICENSE >> $COPYRIGHT INSTALLED_SIZE=$(du -B 1024 -s $DEST | awk '{print $1}') mkdir $DIST/DEBIAN diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 8100a6823..10e2b9833 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -232,7 +232,7 @@ inline = (mempty <$ comment) <|> (guardEnabled Ext_literate_haskell *> char '|' *> doLHSverb) <|> (str . (:[]) <$> tildeEscape) <|> (str . (:[]) <$> oneOf "[]") - <|> (str . (:[]) <$> oneOf "#&") -- TODO print warning? + <|> (str . (:[]) <$> oneOf "#&~^'`\"[]") -- TODO print warning? -- <|> (str <$> count 1 (satisfy (\c -> c /= '\\' && c /='\n' && c /='}' && c /='{'))) -- eat random leftover characters inlines :: LP Inlines @@ -859,8 +859,14 @@ tok = try $ grouped inline <|> inlineCommand <|> str <$> count 1 inlineChar opt :: LP Inlines opt = bracketed inline +rawopt :: LP String +rawopt = do + contents <- bracketed (many1 (noneOf "]") <|> try (string "\\]")) + optional sp + return $ "[" ++ contents ++ "]" + skipopts :: LP () -skipopts = skipMany (opt *> optional sp) +skipopts = skipMany rawopt inlineText :: LP Inlines inlineText = str <$> many1 inlineChar @@ -883,8 +889,9 @@ inlineEnvironment = try $ do rawEnv :: String -> LP Blocks rawEnv name = do - let addBegin x = "\\begin{" ++ name ++ "}" ++ x parseRaw <- getOption readerParseRaw + rawOptions <- mconcat <$> many rawopt + let addBegin x = "\\begin{" ++ name ++ "}" ++ rawOptions ++ x if parseRaw then (rawBlock "latex" . addBegin) <$> (withRaw (env name blocks) >>= applyMacros' . snd) diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 60d69638b..46f082ccd 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -562,13 +562,11 @@ directive' = do "rubric" -> B.para . B.strong <$> parseInlineFromString top _ | label `elem` ["attention","caution","danger","error","hint", "important","note","tip","warning"] -> - do let tit = B.para $ B.strong $ B.str label - bod <- parseFromString parseBlocks $ top ++ "\n\n" ++ body' - return $ B.blockQuote $ tit <> bod + do bod <- parseFromString parseBlocks $ top ++ "\n\n" ++ body' + return $ B.divWith ("",["admonition", label],[]) bod "admonition" -> - do tit <- B.para . B.strong <$> parseInlineFromString top - bod <- parseFromString parseBlocks body' - return $ B.blockQuote $ tit <> bod + do bod <- parseFromString parseBlocks $ top ++ "\n\n" ++ body' + return $ B.divWith ("",["admonition"],[]) bod "sidebar" -> do let subtit = maybe "" trim $ lookup "subtitle" fields tit <- B.para . B.strong <$> parseInlineFromString @@ -576,11 +574,11 @@ directive' = do then "" else (": " ++ subtit)) bod <- parseFromString parseBlocks body' - return $ B.blockQuote $ tit <> bod + return $ B.divWith ("",["sidebar"],[]) $ tit <> bod "topic" -> do tit <- B.para . B.strong <$> parseInlineFromString top bod <- parseFromString parseBlocks body' - return $ tit <> bod + return $ B.divWith ("",["topic"],[]) $ tit <> bod "default-role" -> mempty <$ updateState (\s -> s { stateRstDefaultRole = case trim top of diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 13fe29ca2..4ab0243fe 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -161,9 +161,22 @@ codeBlock = codeBlockBc <|> codeBlockPre codeBlockBc :: Parser [Char] ParserState Blocks codeBlockBc = try $ do - string "bc. " - contents <- manyTill anyLine blanklines - return $ B.codeBlock (unlines contents) + string "bc." + extended <- option False (True <$ char '.') + char ' ' + let starts = ["p", "table", "bq", "bc", "h1", "h2", "h3", + "h4", "h5", "h6", "pre", "###", "notextile"] + let ender = choice $ map explicitBlockStart starts + contents <- if extended + then do + f <- anyLine + rest <- many (notFollowedBy ender *> anyLine) + return (f:rest) + else manyTill anyLine blanklines + return $ B.codeBlock (trimTrailingNewlines (unlines contents)) + +trimTrailingNewlines :: String -> String +trimTrailingNewlines = reverse . dropWhile (=='\n') . reverse -- | Code Blocks in Textile are between <pre> and </pre> codeBlockPre :: Parser [Char] ParserState Blocks @@ -408,14 +421,21 @@ ignorableRow = try $ do _ <- anyLine return () +explicitBlockStart :: String -> Parser [Char] ParserState () +explicitBlockStart name = try $ do + string name + attributes + char '.' + optional whitespace + optional endline + -- | Blocks like 'p' and 'table' do not need explicit block tag. -- However, they can be used to set HTML/CSS attributes when needed. maybeExplicitBlock :: String -- ^ block tag name -> Parser [Char] ParserState Blocks -- ^ implicit block -> Parser [Char] ParserState Blocks maybeExplicitBlock name blk = try $ do - optional $ try $ string name >> attributes >> char '.' >> - optional whitespace >> optional endline + optional $ explicitBlockStart name blk @@ -574,7 +594,7 @@ link = try $ do then char ']' else lookAhead $ space <|> try (oneOf "!.,;:" *> (space <|> newline)) - url <- manyTill nonspaceChar stop + url <- many1Till nonspaceChar stop let name' = if B.toList name == [Str "$"] then B.str url else name return $ if attr == nullAttr then B.link url "" name' diff --git a/stack.full.yaml b/stack.full.yaml index 2f5dc0647..690ad4b99 100644 --- a/stack.full.yaml +++ b/stack.full.yaml @@ -10,16 +10,13 @@ flags: pandoc-citeproc: bibutils: true embed_data_files: true - texmath: - network-uri: true packages: - '.' - '../pandoc-citeproc' - '../pandoc-types' -- '../cmark-hs' -- '../zip-archive' -- '../texmath' extra-deps: -- 'aeson-0.11.1.1' -- 'highlighting-kate-0.6.2' -resolver: lts-5.8 +- http-client-0.5.0 +- http-client-tls-0.3.0 +- data-default-instances-base-0.1.0.1 +- cmark-0.5.3.1 +resolver: nightly-2016-07-11 diff --git a/stack.hsb2hs.yaml b/stack.hsb2hs.yaml index 7dd7899f9..be12b37d5 100644 --- a/stack.hsb2hs.yaml +++ b/stack.hsb2hs.yaml @@ -1,4 +1,4 @@ packages: - 'https://hackage.haskell.org/package/preprocessor-tools-1.0.1/preprocessor-tools-1.0.1.tar.gz' - 'https://hackage.haskell.org/package/hsb2hs-0.3.1/hsb2hs-0.3.1.tar.gz' -resolver: lts-4.0 +resolver: lts-6.5 diff --git a/tests/textile-reader.native b/tests/textile-reader.native index 2e8a6d01c..c617a53f5 100644 --- a/tests/textile-reader.native +++ b/tests/textile-reader.native @@ -25,7 +25,9 @@ Pandoc (Meta {unMeta = fromList []}) ,CodeBlock ("",[],[]) " ---- (should be four hyphens)\n\n sub status {\n print \"working\";\n }\n\n this code block is indented by one tab" ,Para [Str "And:"] ,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{" -,CodeBlock ("",[],[]) "Code block with .bc\n continued\n @</\\\n" +,CodeBlock ("",[],[]) "Code block with .bc\n continued\n @</\\" +,CodeBlock ("",[],[]) "extended code block\n\n continued" +,Para [Str "ended",Space,Str "by",Space,Str "paragraph"] ,Para [Str "Inline",Space,Str "code:",Space,Code ("",[],[]) "<tt>",Str ",",Space,Code ("",[],[]) "@",Str "."] ,Header 1 ("notextile",[],[]) [Str "Notextile"] ,Para [Str "A",Space,Str "block",Space,Str "of",Space,Str "text",Space,Str "can",Space,Str "be",Space,Str "protected",Space,Str "with",Space,Str "notextile",Space,Str ":"] @@ -94,6 +96,7 @@ Pandoc (Meta {unMeta = fromList []}) ,Header 2 ("explicit",[],[]) [Str "Explicit"] ,Para [Str "Just",Space,Str "a",Space,Link ("",[],[]) [Str "url"] ("http://www.url.com","")] ,Para [Link ("",[],[]) [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")] +,Para [Str "\"not",Space,Str "a",Space,Str "link\":",Space,Str "foo"] ,Para [Str "Automatic",Space,Str "linking",Space,Str "to",Space,Link ("",[],[]) [Str "http://www.example.com"] ("http://www.example.com",""),Str "."] ,Para [Link ("",[],[]) [Str "Example"] ("http://www.example.com/",""),Str ":",Space,Str "Example",Space,Str "of",Space,Str "a",Space,Str "link",Space,Str "followed",Space,Str "by",Space,Str "a",Space,Str "colon."] ,Para [Str "A",Space,Str "link",Link ("",[],[]) [Str "with",Space,Str "brackets"] ("http://www.example.com",""),Str "and",Space,Str "no",Space,Str "spaces."] diff --git a/tests/textile-reader.textile b/tests/textile-reader.textile index 6c6754997..cb9a68313 100644 --- a/tests/textile-reader.textile +++ b/tests/textile-reader.textile @@ -68,6 +68,11 @@ bc. Code block with .bc continued @</\ +bc.. extended code block + + continued +p. ended by paragraph + Inline code: @<tt>@, <tt>@</tt>. h1. Notextile @@ -169,6 +174,8 @@ Just a "url":http://www.url.com "Email link":mailto:nobody@nowhere.net +"not a link": foo + Automatic linking to "$":http://www.example.com. "Example":http://www.example.com/: Example of a link followed by a colon. |