Skip to content

Commit

Permalink
Improve abstract in HTML template.
Browse files Browse the repository at this point in the history
* Add localized title "abstract", unless `abstract-title` variable
  is set.
* Add `abstract-title` div to abstract CSS.
* Move abstract CSS out of CSL conditional.
* Ensure that abstract is aligned left but indented on all sides.
* Use smaller font for abstract.

Improves #7588.
  • Loading branch information
jgm committed Jan 9, 2022
1 parent d908e31 commit 2e50c8d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions data/templates/default.html4
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ $if(date)$
$endif$
$if(abstract)$
<div class="abstract">
<div class="abstract-title">$abstract-title$</div>
$abstract$
</div>
$endif$
Expand Down
1 change: 1 addition & 0 deletions data/templates/default.html5
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ $if(date)$
$endif$
$if(abstract)$
<div class="abstract">
<div class="abstract-title">$abstract-title$</div>
$abstract$
</div>
$endif$
Expand Down
19 changes: 13 additions & 6 deletions data/templates/styles.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@
border-left: 2px solid #e6e6e6;
color: #606060;
}
$if(abstract)$
div.abstract {
margin: 2em 2em 2em 2em;
text-align: left;
font-size: 85%;
}
div.abstract-title {
font-weight: bold;
text-align: center;
padding: 0;
margin-bottom: 0.5em;
}
$endif$
code {
font-family: $if(monofont)$$monofont$$else$Menlo, Monaco, 'Lucida Console', Consolas, monospace$endif$;
$if(monobackgroundcolor)$
Expand Down Expand Up @@ -161,12 +174,6 @@
$if(csl-entry-spacing)$
margin-bottom: $csl-entry-spacing$;
$endif$
$if(abstract)$
div.abstract{
margin: auto;
width: 90%;
}
$endif$
}
.hanging div.csl-entry {
margin-left:2em;
Expand Down
6 changes: 5 additions & 1 deletion src/Text/Pandoc/Writers/HTML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import Text.DocLayout (render, literal, Doc)
import Text.Blaze.Internal (MarkupM (Empty), customLeaf, customParent)
import Text.DocTemplates (FromContext (lookupContext), Context (..))
import Text.Blaze.Html hiding (contents)
import Text.Pandoc.Translations (Term(Abstract))
import Text.Pandoc.Definition
import Text.Pandoc.Highlighting (formatHtmlBlock, formatHtmlInline, highlight,
styleToCss)
Expand All @@ -65,7 +66,8 @@ import System.FilePath (takeBaseName)
import Text.Blaze.Html.Renderer.Text (renderHtml)
import qualified Text.Blaze.XHtml1.Transitional as H
import qualified Text.Blaze.XHtml1.Transitional.Attributes as A
import Text.Pandoc.Class.PandocMonad (PandocMonad, report)
import Text.Pandoc.Class.PandocMonad (PandocMonad, report,
translateTerm)
import Text.Pandoc.Class.PandocPure (runPure)
import Text.Pandoc.Error
import Text.Pandoc.Logging
Expand Down Expand Up @@ -267,6 +269,7 @@ pandocToHtml opts (Pandoc meta blocks) = do
let descriptionMeta = literal $ escapeStringForXML $
lookupMetaString "description" meta
slideVariant <- gets stSlideVariant
abstractTitle <- translateTerm Abstract
let sects = adjustNumbers opts $
makeSections (writerNumberSections opts) Nothing $
if slideVariant == NoSlides
Expand Down Expand Up @@ -355,6 +358,7 @@ pandocToHtml opts (Pandoc meta blocks) = do
(if stMath st
then defField "math" math
else id) .
defField "abstract-title" abstractTitle .
(case writerHTMLMathMethod opts of
MathJax u -> defField "mathjax" True .
defField "mathjaxurl"
Expand Down

0 comments on commit 2e50c8d

Please sign in to comment.