markdown.obisidian.personal.note_processing

Process notes to extract basic information about them
from trouver.helper.tests 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_html_tags: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.

Even if remove_html_tags is set to True, only the HTML tags which are written within a single line of text are removed.*

Type Default Details
markdown_file Union
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_html_tags bool True If True, remove HTML tags. Defaults to True`` | | remove_links | bool | True | IfTrue, removes nonembedded links and replaces them with their display text. Defaults toTrue. | | remove_in_line_tags | bool | True | IfTrue, removes in-line tags (the lines that start with a tag). Defaults toTrue. | | remove_footnotes_to_embedded | bool | True | IfTrue, removes footnotes to embedded notes. Defaults toTrue. | | remove_headers | bool | True | IfTrue, removes headers. Defaults toTrue. | | remove_citation_footnotes | bool | True | IfTrue, removes the citation footnote. Defaults toTrue. | | replace_embedded_links_with_content | bool | True | IfTrue, replaces embedded links with their content. Defaults toTrue. | | merge_display_math_mode | bool | True | IfTrue, merge each group of display math mode latex lines into single lines. Defaults toTrue. | | merge_display_math_mode_into_text | Optional | None | If notNone, 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 toNone. The blank character and the new-line characterare recommended as arguments. | | no_double_blank_lines | bool | True | IfTrue, removes escape characters‘’to make it so that there are no double blank lines. Defaults toTrue. | | **Returns** | **MarkdownFile** | | **Ifmarkdown_fileis a [MarkdownFile](https://hyunjongkimmath.github.io/trouver/markdown.markdown.file.html#markdownfile) object, then the output ismarkdown_fileitself (not a copy) with modifications. Ifmarkdown_fileis astr, then the output is a [MarkdownFile`](https://hyunjongkimmath.github.io/trouver/markdown.markdown.file.html#markdownfile) object with the modifications.**
# TODO: add examples