Skip to content

More thoughts on keeping preview at right place. #435

@jonbcooper

Description

@jonbcooper

I have been reading the excellent summary of this issue (#427). Someone (ciri) made the great suggestion to use the following command at the end of the markdown to make the preview move to the desired position. The big number will make it move to the end so you have to find the right number by testing if you want it to go somewhere else.

<script> window.scroll(0,200000) </script>

A variation on that theme is to put in an invisible html identifier in a blank line wherever you are working in the document e.g. "active" as below:

<p id="active"></p>

If you change the window scroll script to:

<script> window.document.getElementById("active").scrollIntoView({block: "center"}) </script>

That will always keep the active paragraph in the centre of the preview window. You can change it to say {block: "start"} if you want the top of the active paragraph at the top of the screen.

There is a bit more info on the scrollIntoView() method here.

When you work on a different paragraph, just cut and paste the <p id="active"></p> to that part of the document.

You can also add the identifier to a subtitle in markdown as follows: #### My subtitle {#active}.

I am sure we can do more with this!

[EDIT. I have just seen that #434 addresses the problem by doing essentially the same thing in python. Nice one.]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions