markdown.obsidian.personal.information_notes

Functions for parsing and modifying standard and module information notes
from fastcore.test import *

from trouver.helper import _test_directory

Look in See Also section

The see also section of a standard information note contains bulleted lists of links to related notes.

These related notes include common terms notes and notation notes.


source

Get the main content of the Standard information note


source

main_content

 main_content (note:trouver.markdown.obsidian.vault.VaultNote)

The main content of the standard information note.

This is the text not in the yaml frontmatter and not the '#See Aslo' section and below.

Parameters - note: VaultNote - A standard information note.

Returns - str

Identify reference that the information note belongs to

Each information note tends to “come from” a reference. The following is a function to identify which reference the information note comes from.


source

reference_of_information_note

 reference_of_information_note
                                (note:trouver.markdown.obsidian.vault.Vaul
                                tNote)

Returns the reference note that the information note probably comes from.

TODO

Parameters - note - VaultNote - A standard information note

Returns - VaultNote


source

reference_notes_in_references_section_of_information_note

 reference_notes_in_references_section_of_information_note
                                                            (note:trouver.
                                                            markdown.obsid
                                                            ian.vault.Vaul
                                                            tNote)

Returns a list of [ObsidianLink](https://hyunjongkimmath.github.io/trouver/markdown.obsidian.links.html#obsidianlink) objects corresponding to reference notes in the “References” section of the information note.

Parameters - note - VaultNote - A standard information note

Returns - list of [ObsidianLink](https://hyunjongkimmath.github.io/trouver/markdown.obsidian.links.html#obsidianlink)

# TODO: examples

Note creation

I think that one of the things that takes me a lot of time while making my math vault is the following process: 1. Creating notes 2. Inserting the template 3. Filling in the note 4. Renaming the note and its title 5. Linking the note to the appropriate index note.

Creating notes and linking them to the index note

Here, I will address 1, 2, and 5; 1 can be done with the [VaultNote](https://hyunjongkimmath.github.io/trouver/markdown.obsidian.vault.html#vaultnote) class. Then, fill in the blank notes with a template and then link them to the appropriate index note

When creating/filling in the note, it can be useful to add tags. For example, I can add a tag to indicate that the note was autogenerated.


source

citation_location_string

 citation_location_string (citation_location:tuple[str,int])

Formats a pair specifying the Numbering label and page

Parameters - citation_location - 2-tuple or empty tuple - Consists of a label str and a page number indicating where in the note’s reference text the note’s information originates from, e.g. the label might be the str ‘Theorem 1.2.3’ and the page number might be the int 85.


source

fill_info_note_with_template

 fill_info_note_with_template
                               (vn:trouver.markdown.obsidian.vault.VaultNo
                               te, template:trouver.markdown.obsidian.vaul
                               t.VaultNote,
                               citation_location:tuple[str,int]=(),
                               content:str='', tags_to_add:Union[str,list[
                               str],tuple[str],NoneType]=None)

Fills in the note with a template with optionally tags.

Current implementation adds content to line 5 of the note.

Parameters - vn - [VaultNote](https://hyunjongkimmath.github.io/trouver/markdown.obsidian.vault.html#vaultnote) - template - [VaultNote](https://hyunjongkimmath.github.io/trouver/markdown.obsidian.vault.html#vaultnote) - citation_location - 2-tuple or empty tuple - Consists of a label str and a page number indicating where in the note’s reference text the note’s information originates from, e.g. the label might be the str ‘Theorem 1.2.3’ and the page number might be the int 85. - content - str - Content to add to the note. Defaults to the empty str. - tags_to_add - str or list of str or tuple of str or None - Each str is just the name of the tag without the leading hashtag. Defaults to None, in which case no tags are added.


source

Getting an index note


source

index_note_of_a_directory

 index_note_of_a_directory (vault:os.PathLike, directory:os.PathLike)

Return the index note in a directory in an Obsidian.md vault, if it exists.

Assumes that the directory has at most one index note.

Raises

  • RuntimeError
    • If more than one index note exists in the directory.
Type Details
vault PathLike
directory PathLike Relative to vault
Returns typing.Optional[trouver.markdown.obsidian.vault.VaultNote] Either the index note in the directory if it exists or None
# TODO: examples
vault = _test_directory() / 'test_vault_5'

sample_output = index_note_of_a_directory(vault, directory='algebra')
assert sample_output is not None
test_eq(sample_output.name, '_index_algebra')

sample_output = index_note_of_a_directory(vault, directory='')
assert sample_output is not None
test_eq(sample_output.name, '_index')

If there is more than one index note in a directory, then a RuntimeError is raised:

vault = _test_directory() / 'test_vault_5'

with ExceptionExpected(RuntimeError):
    sample_output = index_note_of_a_directory(vault, directory='folder_with_more_than_one_index_note')

source

index_note_of_note

 index_note_of_note (note:trouver.markdown.obsidian.vault.VaultNote)

Return the index note indexing the specified note.

note is assumed to either be an information note or itself an index note.

Assumes that a note in indexed in at most one index note and that this index note is either in the same directory as the note or in the immediate parent directory of the note.

Raises

  • UserWarning
    • If an index note that is supposed to index note exists, but does not actually index note.
Type Details
note VaultNote An information note or an index note
Returns typing.Optional[trouver.markdown.obsidian.vault.VaultNote] The index note which indexes note. If no such index note exists (in either the same directory as or the immediate parent directory of the note), then None is returned. In particular, None is returned if note is the root index note of the vault.
# TODO: examples
vault = _test_directory() / 'test_vault_5'

# The index note is in the parent directory of the directory that `info_note` is in.
info_note = VaultNote(vault, name='number_theory_reference_1_Definition 1.1')
sample_output = index_note_of_note(info_note)
assert sample_output is not None
test_eq(sample_output.name, '_index_1_chapter_number_theory_reference_1')


# Here, we have an `index_note` and we are trying to find its index note, which is 
# in the parent directory of the directory that `index_note` is in.
index_note = VaultNote(vault, name='_index_1_chapter_number_theory_reference_1')
sample_output = index_note_of_note(index_note)
assert sample_output is not None
test_eq(sample_output.name, '_index_number_theory_reference_1')

# Here, we have the `root_index_note` of the vault, which is in the root directory
# of the vault. This root index note does not have an index note.
root_index_note = VaultNote(vault, name='_index')
sample_output = index_note_of_note(root_index_note)
assert sample_output is None

# Here, we have `info_note` that is in the same directory as its index note.
info_note = VaultNote(vault, name='number_theory_reference_1_note_in_same_directory_as_index_note')
sample_output = index_note_of_note(info_note)
assert sample_output is not None
test_eq(sample_output.name, '_index_2_chapter_number_theory_reference_2')
AssertionError: