diff options
| author | Albert Krewinkel <albert@zeitkraut.de> | 2023-03-13 17:26:56 +0100 |
|---|---|---|
| committer | Albert Krewinkel <albert@zeitkraut.de> | 2023-03-13 17:31:12 +0100 |
| commit | 51750d6d9aa03c295a050db3c96a51ea27727c5e (patch) | |
| tree | 06819bd9e05a02488f6be9559cdb35ecdce3ab0a | |
| parent | 39eb4145baa96909053fc2b9751ca3041d9efe53 (diff) | |
Jira reader: add panel title as nested div
The title of a jira panel is added in a nested div as the first element
of the div panel.
Fixes: #8681
| -rw-r--r-- | src/Text/Pandoc/Readers/Jira.hs | 12 | ||||
| -rw-r--r-- | test/command/8681.md | 14 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Jira.hs b/src/Text/Pandoc/Readers/Jira.hs index 4eb637895..7a58c7643 100644 --- a/src/Text/Pandoc/Readers/Jira.hs +++ b/src/Text/Pandoc/Readers/Jira.hs @@ -12,6 +12,7 @@ Conversion of jira wiki formatted plain text to 'Pandoc' document. module Text.Pandoc.Readers.Jira ( readJira ) where import Control.Monad.Except (throwError) +import Data.List (partition) import Data.Text (Text, append, pack, singleton) import Text.Pandoc.XML (lookupEntity) import Text.Jira.Parser (parse) @@ -76,7 +77,16 @@ toPandocCodeBlocks langMay params txt = -- | Create a pandoc @'Div'@ from a panel. toPandocDiv :: [Jira.Parameter] -> [Jira.Block] -> Blocks toPandocDiv params = - divWith ("", ["panel"], map paramToPair params) . foldMap jiraToPandocBlocks + let (titles, params') = partition ((== "title") . Jira.parameterKey) params + addTitle = case titles of + [] -> + id + (title:_) -> \blks -> + (divWith ("", ["panelheader"], []) . plain . strong $ + text (Jira.parameterValue title)) <> blks + in divWith ("", ["panel"], map paramToPair params') + . addTitle + . foldMap jiraToPandocBlocks paramToPair :: Jira.Parameter -> (Text, Text) paramToPair (Jira.Parameter key value) = (key, value) diff --git a/test/command/8681.md b/test/command/8681.md new file mode 100644 index 000000000..eb9a812bf --- /dev/null +++ b/test/command/8681.md @@ -0,0 +1,14 @@ +# Include Jira panel title in resulting div +``` +% pandoc -f jira -t html +{panel:title=This is the title|titleBGColor=#cccccc|bgColor=#eeeeee} +Panel content +{panel} +^D +<div class="panel" data-titleBGColor="#cccccc" data-bgColor="#eeeeee"> +<div class="panelheader"> +<strong>This is the title</strong> +</div> +<p>Panel content</p> +</div> +``` |
