ts-markdown has a few entries with the append property. While this was a neat idea at first, more ideas are coming to mind about utilities that would be useful, above and beyond append.
Create a series of utility MarkdownEntry types.
Ideas so far:
AppendEntry : takes whatever text was rendered and appends additional content
PrependEntry : takes whatever text was rendered and prepends additional content
ToLowerCaseEntry
ToUpperCaseEntry
TrimEntry
Reason:
There are scenarios where you are unable to reliably perform some quick modifications to an array of markdown entries. For example, certain information is not available at the point where a paragraph is created, and now the paragraph needs to be prepended with some text. Rather than write a bunch of duck typing code to handle every possible scenario, utility entries could build these kinds of post-process needs into markdown rendering via data decoration.
What would the code look like?
// Example: prepend some markdown content to the first item in an array of markdown entries
/*
Let's say the entries are supposed to read:
This is some text.
Nice!
*/
let someEntries = getSomeEntriesFromSomewhere();
let firstEntryWithPrepend = {
utilPrepend: {
text: [bold("Note:")], entry: someEntries[0]
}
};
someEntries.splice(0, 1, firstEntryWithPrepend);
/*
Now, it should read:
Note: This is some text.
Nice!
*/
Now, take that idea and create helper functions to help with managing the array mutation / copying:
// Example: prepend some markdown content to the first item in an array of markdown entries
/*
Let's say the entries are supposed to read:
This is some text.
Nice!
*/
let someEntries = getSomeEntriesFromSomewhere();
let someEntriesWithPrepend = prependFirst(someEntries, { text: [bold("Note: ")] });
/*
`someEntriesWithPrepend` should read:
Note: This is some text.
Nice!
*/
This is just a rough sketch of the idea and it will surely evolve after some more thought and experimentation.
ts-markdown has a few entries with the
append
property. While this was a neat idea at first, more ideas are coming to mind about utilities that would be useful, above and beyondappend
.Create a series of utility MarkdownEntry types.
Ideas so far:
Reason: There are scenarios where you are unable to reliably perform some quick modifications to an array of markdown entries. For example, certain information is not available at the point where a paragraph is created, and now the paragraph needs to be prepended with some text. Rather than write a bunch of duck typing code to handle every possible scenario, utility entries could build these kinds of post-process needs into markdown rendering via data decoration.
What would the code look like?
Now, take that idea and create helper functions to help with managing the array mutation / copying:
This is just a rough sketch of the idea and it will surely evolve after some more thought and experimentation.