summaryrefslogtreecommitdiff
path: root/src/ast.rs
AgeCommit message (Collapse)AuthorFilesLines
2023-01-28refactor: move YamlMetadata to src/metadata.rsLars Wirzenius1-172/+0
YamlMetadata was in src/ast.rs, because originally it was only used to parse metadata out of Markdown. Markdown parsing is now in its own module, leaving ast.rs to only contain YamlMetadata. In this situation, it seems tidy to have both kinds of metadata in the same module, and to drop the now-empty ast.rs module. Sponsored-by: author
2023-01-22chore: unused code from ast.rsLars Wirzenius1-105/+1
Sponsored-by: author
2023-01-22refactor: create Metadata from YamlMetadata without pandoc_astLars Wirzenius1-0/+55
We don't want to use pandoc_ast outside of the md module. Sponsored-by: author
2023-01-22refactor: drop abstract syntax tree built using pulldown_cmarkLars Wirzenius1-220/+2
We'll want to use the new Markdown type instead. Sponsored-by: author
2023-01-22chore: compile YamlMetadata::new only for testsLars Wirzenius1-0/+1
YamlMetadata::new is only used in unit tests, so disable it when not testing. Sponsored-by: author
2022-12-28refactor: drop unused extract_metadata functionLars Wirzenius1-45/+0
This was orphaned when we dropped the functionality to extract YAML metadata embedded in the Markdown source. Because the function was exported, tools didn't complain that it's unused. Sponsored-by: author
2022-11-12chore: fix unnecessary borrows found by clippyLars Wirzenius1-1/+1
Sponsored-by: author
2022-10-25feat! subplot metadata field for authorsLars Wirzenius1-3/+7
Rename the field "author", which takes a single string value, to "authors", which takes a list of strings. This way we're consistent for single- and multi-author documents. Sponsored-by: author
2022-10-22xxxLars Wirzenius1-1/+0
Sponsored-by: author
2022-10-22feat: allow arbitrary Pandoc metadata in a .subplotLars Wirzenius1-1/+36
The "pandoc" key gets added to the metadata given to Pandoc as-is. Sponsored-by: author
2022-09-06feat! read document metadata from a YAML fileLars Wirzenius1-24/+14
This is a huge change all in one commit, sorry. However, as it changes a fundamental part of the command line interface (namely, what constitutes as the input file), there doesn't seem a way to break this into a tidy series of small commits. Most of the diff is in subplot.md, where every scenario that invokes Subplot needs multiple changes, thus touching much of the file. The overall change is that where we previously had document metadata in embedded YAML in the Markdown file, we now have it in a separate YAML file. The Markdown file is named in the YAML file. We still parse the Markdown with Pandoc for everything, except codegen. Switching from Pandoc to pulldown_cmark for parsing will be another big change that I didn't want to include in this huge change set. Sponsored-by: author
2022-09-03refactor: AST only parses Markdown, YAML is extracted outside itLars Wirzenius1-23/+8
Sponsored-by: author
2022-09-03refactor: expose functionality to extract embedded YAML from mdLars Wirzenius1-53/+35
Sponsored-by: author
2022-09-03refactor: delay use of pandoc_ast::Map to as late as possibleLars Wirzenius1-8/+6
Use YamlMetadata instead. I find this to be clearer and that it reduces the coupling with pandoc_ast a little. This should help us when we implement document metadata in a separate YAML file instead of embedding it in the Markdown. Sponsored-by: author
2022-09-03refactor: make long function a little more readable with empty linesLars Wirzenius1-0/+10
Sponsored-by: author
2022-09-03refactor: use the more idiomatic Into to convert &str to StringLars Wirzenius1-13/+9
The helper function was unnecessary baggage, written by an inexperienced Rust programmer (i.e., me, three years ago). It's time to let go. Sponsored-by: author
2022-09-03refactor: rename ast::Metadata to ast::YamlMetadata for clarityLars Wirzenius1-6/+6
This reduces the confusion with metadata::Metadata and Pandoc's metadata. Sponsored-by: author
2022-03-24feat! change logging to use log/env_logger instead of tracingLars Wirzenius1-31/+24
We don't use async in Subplot, and the mental overhead of learning tracing and the code overhead to add support for logging custom values (implementing the Value trait for Subplot internal types) does not seem worthwhile. Sponsored-by: author
2022-03-12(chore): Update various crates a bit moreDaniel Silverstone1-1/+3
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-11-19ast: Build images into the partial ASTDaniel Silverstone1-1/+10
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-11-19ast: Pass bibliographies on properlyDaniel Silverstone1-1/+1
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-11-19subplot: Rework for impls not template/functionsDaniel Silverstone1-13/+19
As the next step in polyglot documents, this reworks the internals to expect the metadata of documents to contain an impls mapping from template name to function filenames for that template. Sadly this does mean that if there're no function files, the document author will have to still specify an empty list, but that seems acceptable. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-10-17fix: regex for extracting YAML from MarkdownLars Wirzenius1-9/+15
The old regex had a wrong, and weird, pattern for lines of YAML. The new one is simpler and seems more correct: it matches lines not staring with a dot. Sponsored-by: author
2021-10-12fix(portability): avoid using str::split_onceLars Wirzenius1-1/+3
Sequoia wants Rust 1.48.0 and split_once is not in that version. We can easily accommodate Sequoia's needs here with a simple change. Sponsored-by: author
2021-09-18feat: allow the `documentclass` field in document metadataLars Wirzenius1-0/+4
With the new pulldown-cmark parser for codegen, we are explicit about what fields we allow in the YAML document metadata block. We currently don't allow the `documentclass` field. Allow it. It's a useful way for controlling typesetting vie LaTeX to PDF. Sponsored-by: author
2021-09-18ast: codeblocks with single words are classes not IDsDaniel Silverstone1-3/+4
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-18ast: Codeblocks should not have extra trailing newlinesDaniel Silverstone1-0/+6
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-16feat! parse Markdown input with pull-cmark instead of PandocLars Wirzenius1-0/+455
This is a first step towards being able to use Subplot codegen from a project's build.rs, and with only pure-Rust build dependencies. Replace Pandoc for parsing Markdown input with pulldown-cmark. This is mostly a drop-in replacement, but not entirely. The YAML parsing is more strict now. Note that this is a breaking change. Some subplots that used to work, and still work with docgen, no longer work with the new parser. Major differences are: * Only specific fields are supported. All the Markdown files in the Subplot source tree work. If anything else is needed, and it likely is, the new parser needs to be extended. * The bindings, functions, classes, and bibliography fields MUST be lists of strings. A single string value will no longer work. Sponsored-by: pep.foundation
2020-09-19refactor: split src/ast.rs into src/doc.rs and src/style.rsLars Wirzenius1-455/+0
Also, fix anywhere that's affected by the change.
2020-09-01feat(docgen): typeset links as footnotes in PDFLars Wirzenius1-7/+34
When reading a PDF printed on paper or on a reMarkable tablet, it's not possible to see that there even is a link in a PDF. Make this more visible by typesetting the link URL as a footnote. This is not done on HTML output as web pages are read on browsers that make links easy to see. This is the first time the AST is transformed by docgen differently based on the output format. The decision of what should be done is a policy decision, best done at the topmost level: in the main function of docgen. The result of that decidion (turn links into footnotes or not) is communicated from docgen main into the ast.rs module via a new Style struct. This mechanism can later be extended for other typesetting style decisions (e.g., what fonts to use).
2020-08-08refactor: split stuff from src/ast.rs into smaller modulesLars Wirzenius1-733/+16
This only moves things around, to avoid huge source code modules. It doesn't rename functions, add unit tests, or similar. * src/datafiles.rs: DataFile, DataFiles * src/metata.rs: Metadata * src/panhelper.rs: functions for querying Pandoc Attrs * src/policy.rs: the get_basedir_from function; place for later policy functions * src/typeset.rs: functions to produce Pandoc AST nodes * srv/visitor/*: various MutVisitor implementations for traversing ASTs, and their helper functions
2020-06-20Merge branch 'extract' into 'master'Daniel Silverstone1-0/+2
Add sp-extract Closes #41 See merge request larswirzenius/subplot!53
2020-06-08refactor: export DataFile so programs can use embedded filesLars Wirzenius1-0/+2
This will be used soon by a program to extract data files from subplots, but I expect it to be more generally useful in the future.
2020-06-06feat: Support reporting error when more than one binding matches a stepDaniel Silverstone1-9/+10
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2020-05-24feat: Add linting for add-newline attributeDaniel Silverstone1-0/+41
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2020-05-24feat: support adding newlines to filesDaniel Silverstone1-7/+25
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2020-05-20feat!: allow multiple bindings and functions filesLars Wirzenius1-37/+33
Where previously the document metadata could specify a single bindings file, and a single functions file, it can now specify one or more. If a single value is given, that's the filename. Otherwise, it can be a YAML list of filenames. Drop the functions_filename template variable, which was effectively unused, and for which there is no recorded use case at this time.
2020-05-09Merge branch 'keepkeyword' into 'master'Daniel Silverstone1-6/+1
Change: keep actual text of keyword from scenario Closes #24 See merge request larswirzenius/subplot!38
2020-05-09Change: keep actual text of keyword from scenarioLars Wirzenius1-6/+1
The typesetting should preserve the actual keyword or alias in the source. Previously, if source had this: ``` given foo and bar ``` it got typeset as if were: ``` given foo given bar ``` Also, change subplot.md to use alias when possible.
2020-05-09Change: use a base directory for relative pathsLars Wirzenius1-30/+87
This moves the policy decision of what the base directory is to the main functions of the various programs, instead of hiding it deep in the call stack and making it implicitly the current working directory.
2020-05-09Merge branch 'kinnison/issue-21' into 'master'Lars Wirzenius1-3/+88
Add known class names and lint for code blocks with unknown classes Closes #21 See merge request larswirzenius/subplot!35
2020-05-08ast: File header should be paragraphDaniel Silverstone1-1/+1
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2020-05-08ast: Support and lint block class namesDaniel Silverstone1-0/+85
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2020-05-08ast: Fix misleading comment on TypesettingVisitorDaniel Silverstone1-3/+3
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2020-05-02Change: produce docgen output if missing or older than any sourceLars Wirzenius1-7/+103
Source files are: * the markdown file * the bindings, functions, and bibliography files listed in YAML metadata * any included images in the markdown The template file is not considered: it's only relevant for codegen. The docgen binary is not considered, either, for now, because reliably finding the binary is difficult.
2020-05-01Fix: nits found by cargo clippyLars Wirzenius1-5/+2
2020-04-22Change: get Python template from templates/python/template.{yaml.py}Lars Wirzenius1-0/+18
All the language specific details are now in template.yaml, including the command for how to run the generated test program.
2020-04-19Drop: unnecessary to_stringLars Wirzenius1-3/+1
2020-04-19parse: Ensure continuation keywords cannot be used too earlyDaniel Silverstone1-10/+10
We switch from assuming a continuation of `Given` by default to passing Option<StepKind> around and ensuring that we do not succeed in parsing a step if that is None. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2020-04-15Refactor: avoid Pandoc::add_filter, move doc parsing to to ast.rsLars Wirzenius1-0/+9