rc2dev/dotfiles

Templating or changes for kindle2md possible?

Closed this issue · 2 comments

Is there any way to have it apply the same template from fyodor or at least use a different template for the HTML as the structure is slightly different from the normal Clippings.txt?

I currently have this test sample and the current HTML file looks like this. I would like to have it structured the same way as my template.erb file, so:

Book: Romeo and Juliet
Author: William Shakespeare

Highlight 1

Highlight 2

and remove the Copyright page section as well as the location text and bullet point from each highlight. I did find a way to remove the "-" at the beginning of each highlight in the code here:

try:
output = f'# {book_title}\n'
for elem in headings_elements:
output += '\n'
if 'sectionHeading' in elem.attrs['class']:
output += f'## {elem.text.strip()}\n'
else:
text_elem = text_elements.pop(0)
output += f'{text_elem.text.strip()}\n' I removed the "-" here
output += f'\n'
output += f' {parse_description(elem)}\n'
except IndexError as e:
print(f'Error parsing file: {e}')
exit(1)

however, it still leaves a blank space in front of the highlight.

Try replacing lines 63-84 for this:

try:
    book_title = soup.select_one('.bookTitle').text.strip()
    book_author = soup.select_one('.authors').text.strip()
    text_elements = soup.select('.noteText')
except AttributeError as e:
    print(f'Error parsing file: {e}')
    exit(1)

try:
    output = f'# {book_title}\n'
    output += '\n'
    output += f'**Book:** {book_title}\n'
    output += f'**Author:** {book_author}\n'
    for elem in text_elements:
        output += '\n'
        output += f'{elem.text.strip()}\n'
except IndexError as e:
    print(f'Error parsing file: {e}')
    exit(1)

That worked perfectly! Thanks so much! 🙂