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

[jarun#807] fixed import in single-parent-folder-tag mode #814

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LeXofLeviafan
Copy link
Collaborator

fixes #807:

  • when "add single, direct parent folder" tagging mode is enabled, the import behaves consistently with the "add all parent folders" mode (i.e. it applies parent tag to all immediate children, not just the first one)

Example

input file
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
     It will be read and overwritten.
     DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
    <DT><H3>Testing</H3>
    <DL><p>
        <DT><H3>Testing Nested</H3>
        <DL><p>
            <DT><H3>Testing Nested Nested</H3>
            <DL><p>
                <DT><H3>Test</H3>
                <DL><p>
                    <DT><A HREF="https://en.wikipedia.org/wiki/Main_Page#/media/File:The_Death_of_General_Mercer_at_the_Battle_of_Princeton_January_3_1777.jpeg">The Death of General Mercer at the Battle of Princeton January 3 1777 - Wikipedia, the free encyclopedia</A>
                </DL><p>
                <DT><A HREF="https://en.wikipedia.org/wiki/Romania">Romania - Wikipedia</A>
            </DL><p>
            <DT><A HREF="https://en.wikipedia.org/wiki/Main_Page">Wikipedia, the free encyclopedia</A>
        </DL><p>
        <DT><A HREF="https://en.wikipedia.org/wiki/December_(George_Winston_album)">December (George Winston album) - Wikipedia</A>
    </DL><p>
</DL><p>

(before)
before
(after)
after

# dt
# a (could be h3, and continue recursively)
parents = tag.find_parents('dl')
for parent in (parents if use_nested_folder_structure else parents[:1]):
Copy link
Collaborator Author

@LeXofLeviafan LeXofLeviafan Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the else: branch and modified this line in the if: branch (thus ensuring the same code is used for both import-parents-as-tags modes)

@@ -4014,35 +4014,21 @@ def import_html(html_soup: BeautifulSoup, add_parent_folder_as_tag: bool, newtag
desc = comment_tag.find(string=True, recursive=False)

if add_parent_folder_as_tag:
# add parent folder as tag
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this comment (since it was merely quoting the line immediately before it)

@@ -791,7 +791,7 @@ def test_import_html_and_add_parent():
[
("http://example11.com", None, ",folder11,", None, 0, True, False),
("http://example121.com", None, ",folder121,", None, 0, True, False),
("http://example12.com", None, None, None, 0, True, False),
("http://example12.com", None, ",folder12,", None, 0, True, False),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corresponds to a snippet (below) that matches the usecase in question

    <DT><H3>Folder12</H3><DL><p>
        <DT><H3>Folder121</H3><DL><p>
            <DT><A HREF="http://example121.com"></A></DT>
        </DL><p></DT>
        <DT><A HREF="http://example12.com"></A></DT>

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

Successfully merging this pull request may close these issues.

<EMPTY TAG>
1 participant