Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Markdown-Viewer (mdown) document title #36

@jbshirk

Description

@jbshirk

Using the latest version of mdown, I demonstrated to a potential client the elegant usefulness of this app for distributing content easily generated by the non-technical person. Client remarked (and I agree) that the browser tab <title> is hard-coded for all content passed to the app via #hash, and asked if there is a way to make the document title relevant to the specific content displayed. I tried an experiment, a modification, that assumes the first <h1> or <h2> that is generated from the markdown content is intended to be the doc title, and attempted to set the doc tile = firstheadingtext. I was not able to get it to work.

In a simple one-page.html document (not mdown) I confirmed that the following works:

 document.title = document.querySelector("h1, h2").textContent;

But in mdown it is not that simple. I was able to set the title to a dummy at the end of all scripts to verify that changing the location#hash does set the title. But the above code is out of the correct context and spins forever, never finding my <h2> generated from the .md file, and the debugger shows it returns NULL (not an object) so that in fact the page never finishes loading.

I was wondering if someone could give me some pointers on how to access the rendered DOM from within mdown to return the first heading's text. Better ideas are welcome. I am not a js person, if that explains my apparent cluelessness. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions