Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛸 Update extractParts to pull implicit parts based on heading #986

Merged
merged 3 commits into from
Mar 21, 2024

Conversation

fwkoch
Copy link
Collaborator

@fwkoch fwkoch commented Mar 14, 2024

Parts like abstract, acknowledgements, etc. can be tagged and picked up by templates to be used separately from the rest of the content.

Currently there are two ways of defining these parts - (1) putting them under parts in the frontmatter:

---
parts:
  abstract: My abstract!
---

# Introduction

...

or (2) adding metadata to a block with inline JSON:

+++ { "part": "abstract" }

My abstract

+++

# Introduction

...

Both of these require a bit of boilerplate, but worse, if the source for your MyST build is LaTeX, these syntaxes are not available, so you cannot tag a part.


This PR updates the extractPart method to pull out parts based on sections. It looks for headings that match part names and, if found, extracts the subsequent paragraphs as the part. That means you can simply do something like

# Abstract

My Abstract

# Introduction

...

@fwkoch fwkoch requested a review from rowanc1 March 14, 2024 17:00
@rowanc1
Copy link
Collaborator

rowanc1 commented Mar 21, 2024

Works well - will need a bump in the theme to get it over there!

@rowanc1 rowanc1 merged commit 1880a46 into main Mar 21, 2024
4 checks passed
@rowanc1 rowanc1 deleted the feat/implicit-part branch March 21, 2024 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants