Coder Social home page Coder Social logo

abstract-section's Introduction

abstract-section

GitHub build status

Filter that ensures that "Abstract" sections are handled as expected.

Abstract in a dedicated section

This filter allows to write a document abstract as normal sections in the main text. It moves any section titled "abstract" from the main text into the metadata. Most output format templates expect the abstract to be given as part of the metadata, but writing body text is easier and more natural.

# Abstract

Place abstract here.

Multiple paragraphs are possible.

Without this filter, the abstract would need to be placed in the document's metadata. The additional indentation and formatting requirements in YAML headers are frequently perceived as confusing or annoying, especially when writing longer texts.

---
abstract: |
  Place abstract here.

  Multiple paragraphs are possible.
---

This filter modifies the document such that the abstract section behaves as if it was passed as metadata. It does so by looking for a top-level header whose ID is abstract. Pandoc auto-creates IDs based on header contents, so a header titled Abstract will satisfy this condition.^[1]

[1]: This requires the auto_identifier extension. It is enabled by default.

The abstract can be placed anywhere in the document.

The filter assumes that the abstract runs up until the next heading or horizontal rule, whichever comes first. Thus the abstract can be placed at the beginning of a document whose text doesn't start with a heading:

# Abstract

The abstract text includes this.

* * * *

This text is the beginning of the document.

Usage

The filter modifies the internal document representation; it can be used with many publishing systems that are based on pandoc.

Plain pandoc

Pass the filter to pandoc via the --lua-filter (or -L) command line option.

pandoc --lua-filter abstract-section.lua ...

Quarto

Users of Quarto can install this filter as an extension with

quarto install extension pandoc-ext/abstract-section

and use it by adding abstract-section to the filters entry in their YAML header.

---
filters:
  - abstract-section
---

R Markdown

Use pandoc_args to invoke the filter. See the R Markdown Cookbook for details.

---
output:
  word_document:
    pandoc_args: ['--lua-filter=abstract-section.lua']
---

Multiple abstracts

It is common for certain works to include two abstracts, one in English and one in the local language of an academic institution. E.g., theses published at many German universities must have a German "Zusammenfassung" in addition to the English "Abstract".

The filter can be configured to support those additional abstract-like sections as well. The identifiers of the sections must be listed in the section-identifiers field below the abstract-section metadata entry. E.g.:

---
abstract-section:
  section-identifiers:
    - abstract
    - sammanfattning
---

This will place the Abstract in the abstract variable as before, but will also collect the contents of a Sammanfattning section and place it in the sammanfattning field, where it can be used for further processing, e.g., with a custom template.

License

This pandoc Lua filter is published under the MIT license, see file LICENSE for details.

abstract-section's People

Contributors

jdutant avatar jgm avatar tarleb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

abstract-section's Issues

Mutiple section not woring for docx

I'm using the test input file: input-two-sections.md
Then I run the pandoc cmd in window: (I don't know how to install extention for pandoc, so I have to download this filter locally or is there any other way to install?)
pandoc -L abstract-section.lua input-two-sections.md -f markdown -t docx -o test1.docx

The output is:
image

Abstract causes font size to shrink in paragraphs with margins and without footnotes

Font size changes unexpectedly because this extensions causes paragraphs to not be wrapped in the right div.

Faulty behaviour

---
title: "Test"
format: 
  html:
    reference-location: margin
    self-contained: true
filters:
- abstract-section
---

# Abstract

This is an abstract

## A title

Here is some text without a footnote

Here is some text with a footnote^[Look, a footnote]

image

Desired behaviour

---
title: "Test"
format: 
  html:
    reference-location: margin
    self-contained: true
---

---
abstract: |
  This is an abstract
---

## A title

Here is some text without a footnote

Here is some text with a footnote^[Look, a footnote]

image

Error (failed to unzip extension) when trying to install on Windows

The extension works smoothly on a remote linux environment, but I can't install it on my Windows machine:

Microsoft Windows [version 10.0.22621.1265]
(c) Microsoft Corporation. Tous droits réservés.

C:\Users\fbede\Documents\Statistiques\trends_pa_types>quarto install extension pandoc-ext/abstract-section

Quarto extensions may execute code when documents are rendered. If you do not
trust the authors of the extension, we recommend that you do not install or
use the extension.
 ? Do you trust the authors of this extension (Y/n) » Yes
[>] Downloading
abstract-section-main/abstract-section.lua: Can't create '\\\\?\\C:\\Users\\fbede\\AppData\\Local\\Temp\\quarto-sessione8e703cf\\5b007fd5\\0e76a8cd\\archive\\abstract-section-main\\abstract-section.lua'
tar: Error exit delayed from previous errors.
[>] Unzipping
ERROR: Failed to unzip extension.
abstract-section-main/abstract-section.lua: Can't create '\\\\?\\C:\\Users\\fbede\\AppData\\Local\\Temp\\quarto-sessione8e703cf\\5b007fd5\\0e76a8cd\\archive\\abstract-section-main\\abstract-section.lua'
tar: Error exit delayed from previous errors.

Here is my session info:

> sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.utf8  LC_CTYPE=French_France.utf8    LC_MONETARY=French_France.utf8
[4] LC_NUMERIC=C                   LC_TIME=French_France.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.2.2  tools_4.2.2     rstudioapi_0.14 remotes_2.4.2  

Abstract at level > 1

A heading with a level of greater than 1 is ignored by the filter. This causes me a problem if I run Pandoc with --shift-heading-level-by=1. Is there a good reason for the restriction to level 1 headings? If not, could it be removed entirely, or replaced with, e.g., block.level <= 2?

Error running filter abstract-section: Could not find executable abstract-section

Hello and thanks for this cool extension that seems useful.

I am running Quarto in RStudio on an Ubuntu 22.04, with 2022.12.0, R 4.2.2 and quarto 1.2.269.
As per your README, I installed the extension using the terminal:

onyxia@rstudio-32255-0:~/work$ quarto install extension pandoc-ext/abstract-section

Quarto extensions may execute code when documents are rendered. If you do not 
trust the authors of the extension, we recommend that you do not install or 
use the extension.
 ? Do you trust the authors of this extension (Y/n) › Yes
[✓] Downloading
[✓] Unzipping
    Found 1 extension.

The following changes will be made:
pandoc-ext/abstract-section   [Install]   1.0.0 (filter)
 ? Would you like to continue (Y/n) › Yes

[✓] Extension installation complete.
Learn more about this extension at https://www.github.com/pandoc-ext/abstract-section

Then I create a test.qmd file:

---
title: "test"
format: html
editor: visual
filters:
  - abstract-section
---

# Abstract

This is my abstract

****

# Introduction

This is my introduction.

But when I try to render it, I get the following error:

onyxia@rstudio-32255-0:~/work/trends_pa_types$ quarto render test.qmd
pandoc 
  to: html
  output-file: test.html
  standalone: true
  section-divs: true
  html-math-method: mathjax
  wrap: none
  default-image-extension: png
  
metadata
  document-css: false
  link-citations: true
  date-format: long
  lang: en
  title: test
  editor: visual
  
Error running filter abstract-section:
Could not find executable abstract-section

Any idea of how to solve this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.