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

Support include of code snippets in a document #7

Closed
donmendelson opened this issue Sep 3, 2021 · 1 comment
Closed

Support include of code snippets in a document #7

donmendelson opened this issue Sep 3, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@donmendelson
Copy link
Member

Originally entered in tablature project:
FIXTradingCommunity/tablature#37

Some technical specification documents include snippets of code examples or XML elements and the like. Those snippets should remain in source files that can be validated by a language interpreter. Also, source code may be subject to improvements, changes, or corrections over time, but if they are included into a markdown file by copy and paste, they become frozen. Therefore, it would be better to provide a syntax to include snippets dynamically when a Tablature file is processed.

Typically code snippets are bound by markdown fenced code blocks using "```". Rather than literally copying the code into the fenced block, the block would contain syntax to tell a Tablature processor to include a file or section of a file. The source file would need to be accessible at processing time.

@donmendelson donmendelson added the enhancement New feature or request label Sep 3, 2021
@donmendelson
Copy link
Member Author

Markdown fenced code blocks may contain an info string to tell the content type of the block. Originally, this was commonly the name of a programming language to support syntax highlighting. Other names evolved that may correspond to media types, such as "xml".

I propose to extend info string to support specifications for importing content from an external file. Possible syntax:

import <file-path> import an entire file
import <file-path> line <from-line-no> - [line] <to-line-no> import a range of line numbers (inclusive) from an external file. This is generic but could break if the file has additions or deletions.
import <file-path> find <from-text> - [find] <to-text> import a part of file delimited by the specified text. Find from-text matches the first instance of the given text, so it should be unique in the file. Find to-text matches the next instance after the from target, so it need not be unique.
If the "to" target is not given, then the import is "from" target to end of file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant