diff --git a/app/src/main/java/net/gsantner/markor/format/markdown/MarkdownTextConverter.java b/app/src/main/java/net/gsantner/markor/format/markdown/MarkdownTextConverter.java index 69f0be58ff..821017fa0a 100644 --- a/app/src/main/java/net/gsantner/markor/format/markdown/MarkdownTextConverter.java +++ b/app/src/main/java/net/gsantner/markor/format/markdown/MarkdownTextConverter.java @@ -454,17 +454,13 @@ private String replaceTokens(final String markup, final Map // Extension to add line numbers to headings // --------------------------------------------------------------------------------------------- - public static String getIdForLineNumber(final int num) { - return "line-" + num; - } - private static class LineNumberIdProvider implements AttributeProvider { @Override public void setAttributes(Node node, AttributablePart part, Attributes attributes) { if (node instanceof com.vladsch.flexmark.ast.Heading) { final Document document = node.getDocument(); final int lineNumber = document.getLineNumber(node.getStartOffset()); - attributes.addValue("id", getIdForLineNumber(lineNumber)); + attributes.addValue("line", "" + lineNumber); } } } diff --git a/app/src/main/java/net/gsantner/markor/frontend/MarkorDialogFactory.java b/app/src/main/java/net/gsantner/markor/frontend/MarkorDialogFactory.java index 0b6ca4e6f6..0f28a076b6 100644 --- a/app/src/main/java/net/gsantner/markor/frontend/MarkorDialogFactory.java +++ b/app/src/main/java/net/gsantner/markor/frontend/MarkorDialogFactory.java @@ -840,9 +840,7 @@ public static void showHeadlineDialog( final int line = headings.get(index).line; TextViewUtils.selectLines(edit, line); - - final String id = MarkdownTextConverter.getIdForLineNumber(line); - webView.loadUrl(String.format("javascript:document.getElementById('%s').scrollIntoView();", id)); + webView.loadUrl(String.format("javascript:document.querySelector('[line=\"%d\"]').scrollIntoView();", line)); }; dopt.neutralButtonText = R.string.filter;