Skip to content

Commit

Permalink
Jump by a line identifier, not by id
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Jul 26, 2024
1 parent 446d4f9 commit 29f9d47
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -454,17 +454,13 @@ private String replaceTokens(final String markup, final Map<String, List<String>
// 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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 29f9d47

Please sign in to comment.