GhostManager / Ghostwriter

The SpecterOps project management and reporting engine
https://ghostwriter.wiki
BSD 3-Clause "New" or "Revised" License
1.23k stars 174 forks source link

Header bookmarks #460

Open domwhewell-sage opened 2 weeks ago

domwhewell-sage commented 2 weeks ago

Is your feature request related to a problem? Please describe. When adding a link in the tinymce editor you can make it an internal link to a heading -> (Entering in # makes it an internal hyperlink)

image

The tinymce editor then adds an id attribute to the heading tag, e.g.

<h1 id="h_1741158734421718551414403">Introduction</h1>

This id tag is currently stripped and does not end up as a bookmark in the generated docx

Describe the solution you'd like The hyperlink currently gets generated correctly

image

But the bookmark does not

image

It would be good if bookmarks could be added into the renderer

Describe alternatives you've considered I had considered adding in a title_bookmark field to each finding by adding in the function which only adds in the rich text

def bookmark_rich_text(self, text, url):
        bookmark = RichText()
        bookmark.xml = '<w:bookmarkStart w:id="" w:name="{}"/>{}<w:bookmarkEnd w:id=""/>'.format(url, text)
        return bookmark