diff options
-rw-r--r-- | deb/Makefile | 11 | ||||
-rw-r--r-- | deb/Vagrantfile | 73 | ||||
-rw-r--r-- | deb/stack.yaml | 17 | ||||
-rwxr-xr-x | make_deb.sh | 41 | ||||
-rwxr-xr-x | make_osx_package.sh | 17 | ||||
-rw-r--r-- | osx/stack.yaml (renamed from stack.pkg.yaml) | 2 | ||||
-rw-r--r-- | pandoc.cabal | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Org.hs | 35 | ||||
-rw-r--r-- | stack.hsb2hs.yaml | 4 | ||||
-rw-r--r-- | tests/Tests/Readers/Org.hs | 8 |
10 files changed, 180 insertions, 29 deletions
diff --git a/deb/Makefile b/deb/Makefile new file mode 100644 index 000000000..7f514fe24 --- /dev/null +++ b/deb/Makefile @@ -0,0 +1,11 @@ +COMMIT?=HEAD + +.PHONY: package clean + +package: + vagrant up + vagrant ssh -c 'rm -rf pandoc && git clone https://github.com/jgm/pandoc && cd pandoc && git checkout -b work $(COMMIT) && git submodule update --init && ./make_deb.sh && cp *.deb /vagrant_data/' + vagrant halt + +clean: + vagrant destroy diff --git a/deb/Vagrantfile b/deb/Vagrantfile new file mode 100644 index 000000000..f52de8ff9 --- /dev/null +++ b/deb/Vagrantfile @@ -0,0 +1,73 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure(2) do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "ubuntu/trusty64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + config.vm.synced_folder "..", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + config.vm.provider "virtualbox" do |vb| + # Display the VirtualBox GUI when booting the machine + # vb.gui = true + + # Customize the amount of memory on the VM: + vb.memory = "4096" + end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies + # such as FTP and Heroku are also available. See the documentation at + # https://docs.vagrantup.com/v2/push/atlas.html for more information. + # config.push.define "atlas" do |push| + # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" + # end + + # Enable provisioning with a shell script. Additional provisioners such as + # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the + # documentation for more information about their specific syntax and use. + config.vm.provision "shell", inline: <<-SHELL + wget -q -O- https://s3.amazonaws.com/download.fpcomplete.com/debian/fpco.key | sudo apt-key add - + echo 'deb http://download.fpcomplete.com/ubuntu/trusty 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 + SHELL +end diff --git a/deb/stack.yaml b/deb/stack.yaml new file mode 100644 index 000000000..9c9906c05 --- /dev/null +++ b/deb/stack.yaml @@ -0,0 +1,17 @@ +flags: + pandoc: + trypandoc: false + https: true + embed_data_files: true + old-locale: false + network-uri: true + pandoc-citeproc: + bibutils: true + embed_data_files: true + unicode_collation: false + test_citeproc: false + debug: false +packages: +- '..' +- 'https://hackage.haskell.org/package/pandoc-citeproc-0.8.0.1/pandoc-citeproc-0.8.0.1.tar.gz' +resolver: lts-3.10 diff --git a/make_deb.sh b/make_deb.sh index a5aaf1549..9b7960805 100755 --- a/make_deb.sh +++ b/make_deb.sh @@ -7,7 +7,7 @@ case "$MACHINE" in i386) ARCHITECTURE=i386;; esac -SANDBOX=`pwd`/.cabal-sandbox +LOCAL=$HOME/.local VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}') DEBPKGVER=1 DEBVER=$VERSION-$DEBPKGVER @@ -16,41 +16,44 @@ DIST=`pwd`/$BASE DEST=$DIST/usr ME=$(whoami) COPYRIGHT=$DEST/share/doc/pandoc/copyright +TEMPDIR=make_binary_package.tmp.$$ -# echo Removing old files... -rm -rf $DIST +# We need this for hsb2hs: +PATH=$LOCAL/bin:$PATH -cabal sandbox init -echo Updating database -cabal update +stack setup +stack clean +which hsb2hs || stack install --stack-yaml stack.hsb2hs.yaml -export PATH=`pwd`/.cabal-sandbox/bin:$PATH -which hsb2hs || cabal install hsb2hs -echo Building pandoc... -cabal clean -cabal install --force --reinstall --flags="embed_data_files make-pandoc-man-pages" . pandoc-citeproc +stack install --stack-yaml deb/stack.yaml +make man/pandoc.1 # get pandoc-citeproc man page: -PANDOC_CITEPROC_PATH=`cabal unpack -d make_binary_package.tmp.$$ pandoc-citeproc | awk '{print $3;}'` -strip $SANDBOX/bin/pandoc -strip $SANDBOX/bin/pandoc-citeproc +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} + +strip $LOCAL/bin/pandoc +strip $LOCAL/bin/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 -cp $SANDBOX/bin/pandoc $DEST/bin/ -cp $SANDBOX/bin/pandoc-citeproc $DEST/bin/ -cp $SANDBOX/share/man/man1/pandoc.1 $DEST/share/man/man1/pandoc.1 +cp $LOCAL/bin/pandoc $DEST/bin/ +cp $LOCAL/bin/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/ +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 make_binary_package.tmp.$$ +rm -rf $TEMPDIR INSTALLED_SIZE=$(du -B 1024 -s $DEST | awk '{print $1}') mkdir $DIST/DEBIAN diff --git a/make_osx_package.sh b/make_osx_package.sh index 835638c76..a544ad7a0 100755 --- a/make_osx_package.sh +++ b/make_osx_package.sh @@ -12,20 +12,31 @@ BASE=pandoc-$VERSION ME=$(whoami) PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker +# We need this for hsb2hs: +PATH=$LOCALBIN:$PATH + # echo Removing old files... rm -rf $DIST +mkdir -p $DIST mkdir -p $RESOURCES +stack setup +which hsb2hs | stack install --stack-yaml=stack.hsb2hs.yaml echo Building pandoc... -stack install --stack-yaml=stack.pkg.yaml +stack clean +stack install --stack-yaml=osx/stack.yaml echo Getting man pages... make man/pandoc.1 -PANDOC_CITEPROC_PATH=`cabal unpack -d $DIST pandoc-citeproc | awk '{print $3;}'` + +# 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 +curl ${PANDOC_CITEPROC_TARBALL} | tar xzC $DIST +PANDOC_CITEPROC_PATH=$DIST/pandoc-citeproc-${PANDOC_CITEPROC_VERSION} mkdir -p $DEST/bin mkdir -p $DEST/share/man/man1 -mkdir -p $DEST/share/man/man5 for f in pandoc pandoc-citeproc; do cp $LOCALBIN/$f $DEST/bin/; done diff --git a/stack.pkg.yaml b/osx/stack.yaml index e7ce11752..674ebed2c 100644 --- a/stack.pkg.yaml +++ b/osx/stack.yaml @@ -15,6 +15,6 @@ ghc-options: pandoc-citeproc: '-pgmP cpphs -optP--cpp' highlighting-kate: '-pgmP cpphs -optP--cpp' packages: -- '.' +- '..' - 'https://hackage.haskell.org/package/pandoc-citeproc-0.8.0.1/pandoc-citeproc-0.8.0.1.tar.gz' resolver: lts-3.10 diff --git a/pandoc.cabal b/pandoc.cabal index 6365b7944..a44aa3f06 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -433,6 +433,7 @@ Executable pandoc Main-Is: pandoc.hs Buildable: True Other-Modules: Prelude + Paths_pandoc Executable trypandoc Main-Is: trypandoc.hs diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs index 53cc74537..2585ace21 100644 --- a/src/Text/Pandoc/Readers/Org.hs +++ b/src/Text/Pandoc/Readers/Org.hs @@ -2,7 +2,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses, FlexibleContexts, FlexibleInstances #-} {- -Copyright (C) 2014-2015 Albert Krewinkel <tarleb@moltkeplatz.de> +Copyright (C) 2014-2015 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Copyright : Copyright (C) 2014 Albert Krewinkel License : GNU GPL, version 2 or above - Maintainer : Albert Krewinkel <tarleb@moltkeplatz.de> + Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de> Conversion of org-mode formatted plain text to 'Pandoc' document. -} @@ -140,6 +140,7 @@ data OrgParserState = OrgParserState , orgStateMeta :: Meta , orgStateMeta' :: F Meta , orgStateNotes' :: OrgNoteTable + , orgStateParserContext :: ParserContext , orgStateIdentifiers :: [String] , orgStateHeaderMap :: M.Map Inlines String } @@ -181,6 +182,7 @@ defaultOrgParserState = OrgParserState , orgStateMeta = nullMeta , orgStateMeta' = return nullMeta , orgStateNotes' = [] + , orgStateParserContext = NullState , orgStateIdentifiers = [] , orgStateHeaderMap = M.empty } @@ -291,6 +293,23 @@ blanklines = <* updateLastPreCharPos <* updateLastForbiddenCharPos +-- | Succeeds when we're in list context. +inList :: OrgParser () +inList = do + ctx <- orgStateParserContext <$> getState + guard (ctx == ListItemState) + +-- | Parse in different context +withContext :: ParserContext -- ^ New parser context + -> OrgParser a -- ^ Parser to run in that context + -> OrgParser a +withContext context parser = do + oldContext <- orgStateParserContext <$> getState + updateState $ \s -> s{ orgStateParserContext = context } + result <- parser + updateState $ \s -> s{ orgStateParserContext = oldContext } + return result + -- -- parsing blocks -- @@ -903,9 +922,13 @@ noteBlock = try $ do paraOrPlain :: OrgParser (F Blocks) paraOrPlain = try $ do ils <- parseInlines - nl <- option False (newline >> return True) - try (guard nl >> notFollowedBy (orderedListStart <|> bulletListStart) >> - return (B.para <$> ils)) + nl <- option False (newline *> return True) + -- Read block as paragraph, except if we are in a list context and the block + -- is directly followed by a list item, in which case the block is read as + -- plain text. + try (guard nl + *> notFollowedBy (inList *> (orderedListStart <|> bulletListStart)) + *> return (B.para <$> ils)) <|> (return (B.plain <$> ils)) inlinesTillNewline :: OrgParser (F Inlines) @@ -982,7 +1005,7 @@ definitionListItem parseMarkerGetLength = try $ do -- parse raw text for one list item, excluding start marker and continuations listItem :: OrgParser Int -> OrgParser (F Blocks) -listItem start = try $ do +listItem start = try . withContext ListItemState $ do markerLength <- try start firstLine <- anyLineNewline blank <- option "" ("\n" <$ blankline) diff --git a/stack.hsb2hs.yaml b/stack.hsb2hs.yaml new file mode 100644 index 000000000..1703e778f --- /dev/null +++ b/stack.hsb2hs.yaml @@ -0,0 +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-3.10 diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 91c1bb672..66f284b28 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -880,6 +880,14 @@ tests = , para "orange" , para "peach" ] + + , "Recognize preceding paragraphs in non-list contexts" =: + unlines [ "CLOSED: [2015-10-19 Mon 15:03]" + , "- Note taken on [2015-10-19 Mon 13:24]" + ] =?> + mconcat [ para "CLOSED: [2015-10-19 Mon 15:03]" + , bulletList [ plain "Note taken on [2015-10-19 Mon 13:24]" ] + ] ] , testGroup "Tables" |