markdown.obisidian.personal.note_processing

Process notes to extract basic information about them
from trouver.helper import _test_directory
from fastcore.test import *

trouver assumes that the notes in the Obsidian.md math vaults are are roughly of the following format:

vault = _test_directory() / 'test_vault_5'
template_note = VaultNote(vault, name='_template_common')
print(template_note.text())
---
cssclass: clean-embeds
aliases: []
tags: [_meta/literature_note]
---
# Topic[^1]

# See Also

# Meta
## References

## Citations and Footnotes
[^1]: Citation

The functions in this module extract information about such notes. For example, they extract the main text (without the metadata, links, footnotes, etc.) to obtain the “raw” text of the note.


source

remove_double_asterisks_in_markdown_file

 remove_double_asterisks_in_markdown_file
                                           (markdown_file:trouver.markdown
                                           .markdown.file.MarkdownFile)

Remove double asterisks in MarkdownFile object.

The author of trouver chose to implement this function outside of the MarkdownFile class because its use seems specific - this function is mostly intended to remove double asterisks marking definitions and notations introduced in LaTeX text.

mf = MarkdownFile.from_string('Hi. Here are some double asterisks: **')

remove_double_asterisks_in_markdown_file(mf)
test_eq(str(mf), 'Hi. Here are some double asterisks: ')

mf = MarkdownFile.from_string(
    'I want to use double asterisks to surround definitions and notations:'
    ' the **Galois group** **$\operatorname{Gal}(L/K)$** of a Galois extension'
    ' $L/K$ is...')
remove_double_asterisks_in_markdown_file(mf)
test_eq(str(mf), 'I want to use double asterisks to surround definitions and notations: the Galois group $\operatorname{Gal}(L/K)$ of a Galois extension $L/K$ is...')

source

process_standard_information_note

 process_standard_information_note
                                    (markdown_file:Union[trouver.markdown.
                                    markdown.file.MarkdownFile,str],
                                    vault:os.PathLike,
                                    remove_frontmatter_meta:bool=True,
                                    remove_see_also_section:bool=True,
                                    remove_meta_section:bool=True,
                                    remove_references_section:bool=True,
                                    remove_double_asterisks:bool=True,
                                    remove_links:bool=True,
                                    remove_in_line_tags:bool=True, remove_
                                    footnotes_to_embedded:bool=True,
                                    remove_headers:bool=True,
                                    remove_citation_footnotes:bool=True, r
                                    eplace_embedded_links_with_content:boo
                                    l=True,
                                    merge_display_math_mode:bool=True, mer
                                    ge_display_math_mode_into_text:Optiona
                                    l[str]=None,
                                    no_double_blank_lines:bool=True)

Process/modify a str/MarkdownFile of a standard information note.

TODO: implement remove_citation_footnote properly.

Type Default Details
markdown_file typing.Union[trouver.markdown.markdown.file.MarkdownFile, str]
vault PathLike
remove_frontmatter_meta bool True If True, removes the frontmatter meta. Defaults to True
remove_see_also_section bool True If True, removes the # See also section. Defaults to True.
remove_meta_section bool True If True, remove the # Meta section. Defaults to True.
remove_references_section bool True If True, removes the ## References section. Defaults to True.
remove_double_asterisks bool True If True, removes double asterisks. Defaults to True.
remove_links bool True If True, removes nonembedded links and replaces them with their display text. Defaults to True.
remove_in_line_tags bool True If True, removes in-line tags (the lines that start with a tag). Defaults to True.
remove_footnotes_to_embedded bool True If True, removes footnotes to embedded notes. Defaults to True.
remove_headers bool True If True, removes headers. Defaults to True.
remove_citation_footnotes bool True If True, removes the citation footnote. Defaults to True.
replace_embedded_links_with_content bool True If True, replaces embedded links with their content. Defaults to True.
merge_display_math_mode bool True If True, merge each group of display math mode latex lines into single lines. Defaults to True.
merge_display_math_mode_into_text typing.Optional[str] None If not None, merge each group of display math mode latex lines into single lines and merge those groups into the text that precedes them with the specified str. Defaults to None. The blank character and the new-line character \n are recommended as arguments.
no_double_blank_lines bool True If True, removes escape characters '\n' to make it so that there are no double blank lines. Defaults to True.
Returns MarkdownFile If markdown_file is a MarkdownFile object, then the output is markdown_file itself (not a copy) with modifications. If markdown_file is a str, then the output is a MarkdownFile object with the modifications.
# TODO: add examples