Keep comment-opening '%' along with the comment and support empty lines
This commit is contained in:
parent
85e4eb9273
commit
9dac275f68
2 changed files with 5 additions and 4 deletions
|
@ -7,7 +7,7 @@ module PDF.Body (
|
|||
import Control.Applicative ((<|>))
|
||||
import Control.Monad.State (get, gets, modify)
|
||||
import Data.ByteString.Char8 (ByteString)
|
||||
import qualified Data.ByteString.Char8 as BS (drop, unpack)
|
||||
import qualified Data.ByteString.Char8 as BS (cons, drop, unpack)
|
||||
import Data.Map ((!))
|
||||
import qualified Data.Map as Map (empty, insert, lookup)
|
||||
import qualified PDF.EOL as EOL (charset, parser)
|
||||
|
@ -41,8 +41,9 @@ pushOccurrence newOccurrence = modifyFlow $ \flow -> flow {
|
|||
}
|
||||
|
||||
comment :: Parser u String
|
||||
comment = BS.unpack <$>
|
||||
(char '%' *> takeAll (not . (`elem` EOL.charset)) <* EOL.parser)
|
||||
comment = BS.unpack <$> (option "" afterPercent <* EOL.parser)
|
||||
where
|
||||
afterPercent = BS.cons <$> char '%' <*> takeAll (not . (`elem` EOL.charset))
|
||||
|
||||
lookupOffset :: Int -> XRefSection -> Maybe Int
|
||||
lookupOffset _ [] = Nothing
|
||||
|
|
|
@ -242,7 +242,7 @@ data Occurrence = Comment String | Indirect IndirectObjCoordinates deriving Show
|
|||
|
||||
outputOccurrence :: Map Int Object -> Occurrence -> OBuilder
|
||||
outputOccurrence _ (Comment c) =
|
||||
Output.string (printf "%%%s" c) `mappend` newLine
|
||||
Output.string c `mappend` newLine
|
||||
outputOccurrence objects (Indirect (IndirectObjCoordinates {objectId, versionNumber})) =
|
||||
saveOffset (ObjectId objectId)
|
||||
>> Output.string (printf "%d %d obj" objectId versionNumber)
|
||||
|
|
Loading…
Reference in a new issue