Skip to content

Commit

Permalink
🛸 Update extractParts to pull implicit parts based on heading (#986)
Browse files Browse the repository at this point in the history
Co-authored-by: Rowan Cockett <rowanc1@gmail.com>
  • Loading branch information
fwkoch and rowanc1 authored Mar 21, 2024
1 parent 8aca668 commit 1880a46
Show file tree
Hide file tree
Showing 11 changed files with 663 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-peas-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-common': patch
---

Update extractParts to pull implicit parts from sections based on heading
5 changes: 5 additions & 0 deletions .changeset/clean-dots-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tex-to-myst': patch
---

Fix bug where certain affiliations without authors crash tex-to-myst
5 changes: 5 additions & 0 deletions .changeset/tidy-windows-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"myst-frontmatter": patch
---

Expand parts to other aliases
1 change: 1 addition & 0 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ parts:
- file: syntax-overview
- file: directives
- file: frontmatter
- file: document-parts
- file: settings
- file: glossary
- caption: Contribute
Expand Down
2 changes: 1 addition & 1 deletion docs/blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cell 2
```

```{tip}
To identify a part of a document, like an abstract, use `+++ {"part": "abstract"}`, this will allow tools like the [](./creating-pdf-documents.md) to be created with the appropriate parts of information.
To identify a [part of a document](./document-parts.md), like an abstract, use `+++ { "part": "abstract" }`, this will allow tools like the [](./creating-pdf-documents.md) to be created with the appropriate parts of information.
```

## Comments
Expand Down
91 changes: 91 additions & 0 deletions docs/document-parts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: Document Parts
description: Parts allow you to specify special parts of your document, like abstract, keypoints acknowledgements.
---

Document parts allow you to add metadata to your documents with specific components of your page, for example, abstract, dedication, or acknowledgments. Many templates put these in specific places.

There are three ways that you can define parts of a document: (1) in your page frontmatter; (2) implicitly using a section heading; and (3) on a block using a `part` or `tag` annotation.

## Parts in Frontmatter

On any page, you can add a part to your document directly in the frontmatter, for example, the `abstract`:

```yaml
---
title: My document
abstract: |
This is a multi-line
abstract, with _markdown_!
---
```

### Known Frontmatter Parts

The known parts that are recognized as _top-level_ document frontmatter keys are:

abstract
: A concise overview of the entire document, highlighting the main objectives, methods, results, and conclusions. It's meant to give readers a quick snapshot of what to expect without having to read the entire document.

summary
: Similar to an abstract, but can either be slightly longer and more detailed or used as a plain-language summary, depending on the context. It summarizes the document's content, including the background, purpose, methodology, results, and conclusions.
: Alias: `plain_language_summary`, `lay_summary`

keypoints
: A brief list that highlights the main findings, conclusions, or contributions of the document. Key points are often used to quickly convey the core message or most important aspects to the reader.

dedication
: A short section where the author dedicates the document to someone, often as a gesture of honor or respect.

epigraph
: A quote or poem that the author includes at the beginning of the document to set a tone or theme, or to hint at the document’s underlying message. It is often relevant to the content but not directly related to it.
: Alias: `quote`

data_availability
: A statement or section that details how readers can access the data sets and resources used in the document. This can include links to repositories, conditions for access, and any restrictions on the data. It's crucial for transparency and reproducibility in research documents.
: Alias: `availability`

acknowledgments
: A section where the author thanks individuals, organizations, or agencies that contributed to the completion of the document. This can include support in the form of funding, expertise, feedback, or moral support.
: Alias: `ack`, `acknowledgements`

### Custom Frontmatter Parts

If you have a custom part name for a template, you can nest it under `parts:`, which takes arbitrary keys.

```yaml
---
title: My document
parts:
special_part: |
This is a multi-line
abstract, with _markdown_!
---
```

The advantage of this method is that the content is not rendered in your document.

## Implicit Parts using a Title

If you are rendering your project in other places, it can be helpful to leave these sections directly in the document.
Complete this using a header as usual:

```
# Abstract
This is my abstract!
```

Note that frontmatter parts and explicitly tagged cells/blocks will take precedence over this method.

## In a Jupyter Notebook cells and blocks

When using a Jupyter Notebook, you can add a `tag` to the cell with the part name, if multiple cells share that tag, they will be extracted and merged. This can also be represented in a [block](./blocks.md):

```markdown
+++ { "part": "abstract" }

This is my abstract block.

+++
```
22 changes: 12 additions & 10 deletions docs/quickstart-myst-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,25 @@ Once these are added, the myst theme (in this case the `book-theme` template) ca
The myst theme for the `01-paper.md` page after the frontmatter changes are added. Compare this to what it looked like before in [](#frontmatter-before-pdf). The structure of the HTML page has also been improved, including meta tags that are available to search engines and other programmatic indexers.
:::

### Add an abstract block
### Add an abstract part

We will also add data about the "parts" of our document, for example, the abstract. This will be important when we export to PDF and also visually changes the `book-theme`.
We will also add metadata about the "parts" of our document, for example, the abstract.
This will be important when we export to PDF and also visually changes the `book-theme`.

🛠 In `01-paper.md`: surround the abstract in a block `+++ {"part": "abstract"}`
🛠 In `01-paper.md`: move the abstract into the frontmatter using a multiline YAML syntax `abstract: |`

```{code-block} markdown
:linenos:
:emphasize-lines: 1,5
+++ {"part": "abstract"}
We introduce, a set of open-source, community-driven ...
+++
:emphasize-lines: 4,5
---
title: How to MyST, without being mystified 🧙
...
abstract: |
We introduce, a set of open-source, community-driven ...
---
```

You can make other blocks, like `data-availability` or `acknowledgments` or `key-points`, templates will treat these differently and may require specific parts to fully render.
You can make other parts, like `data_availability` or `acknowledgments` or `keypoints`, templates will treat these differently and may require specific parts to fully render. See [document parts](./document-parts.md) for additional information.

### Add a citation

Expand Down
Loading

0 comments on commit 1880a46

Please sign in to comment.