mvdkwast / obsidian-copy-as-html

Obsidian plugin: copy document as HTML, including images
MIT License
42 stars 11 forks source link

Allow embedding only a section of a document #23

Closed jkunczik closed 1 year ago

jkunczik commented 1 year ago

Thank you so much for this awesome plugin! I had the problem that I could not embed sections of another document. When trying, I only got the link text for the embedded file and not more. It turned out the fix was quite simple, hence I quickly added it.

What the changes do:

  1. If the embedding link is interrupted by an "#", then not the whole file, but only a section shall be embedded.
  2. I regular expression then extracts the section in question from the linked document and only sends that to the markdown renderer.
  3. In any case the text of the embedding link (innerHTML) is removed before rendering the embedded markdown.

If you have any questions, please let me know!

mvdkwast commented 1 year ago

Hi @jkunczik ! Thanks a lot, this would close #22. I will try to find some time to review / merge it this week !

mvdkwast commented 1 year ago

Hi @jkunczik, I reviewed your code and suggested some changes to keep the code more like the existing code. Congrats on the regexp art btw :)

When I tested the implementation, it seems that the first header is removed from the copy. This is different from the behaviour in Obsidian, so it would probably be best to keep it in. Do you have a special use-case for this ? It could be removed using a custom stylesheet or with a user-option instead.

mvdkwast commented 1 year ago

@jkunczik, if you agree I will make the changes myself, and credit you for the feature ?

mvdkwast commented 1 year ago

Closes #22