Skip to content

Commit

Permalink
RST reader: support :file: on raw directive.
Browse files Browse the repository at this point in the history
Closes #8584.
  • Loading branch information
jgm committed Oct 24, 2024
1 parent 516931f commit c17c204
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Text/Pandoc/Readers/RST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import qualified Data.Text as T
import Text.Printf (printf)
import Text.Pandoc.Builder (Blocks, Inlines, fromList, setMeta, trimInlines)
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class (PandocMonad, fetchItem, getTimestamp)
import Text.Pandoc.Class (PandocMonad, readFileFromDirs, fetchItem, getTimestamp)
import Text.Pandoc.CSV (CSVOptions (..), defaultCSVOptions, parseCSV)
import Text.Pandoc.Definition
import Text.Pandoc.Error
Expand Down Expand Up @@ -742,7 +742,12 @@ directive' = do
if fieldIndent == 0
then return []
else many $ rawFieldListItem fieldIndent
body <- option "" $ try $ blanklines >> indentedBlock
let mbfile = trim <$> lookup "file" fields
body <- case mbfile of
Just f | label == "raw" -> do
currentDir <- takeDirectory . sourceName <$> getPosition
fromMaybe mempty <$> readFileFromDirs [currentDir] (T.unpack f)
_ -> option "" $ try $ blanklines >> indentedBlock
optional blanklines
let body' = body <> "\n\n"
name = trim $ fromMaybe "" (lookup "name" fields)
Expand Down

0 comments on commit c17c204

Please sign in to comment.