GithubHelp home page GithubHelp logo

Comments (10)

joaompinto avatar joaompinto commented on May 25, 2024

I am looking into this, the VSCode built-in extension for markdown files already does "scroll sync", but the code is somehow complex. I will do some more research on that code.

from asciidoctor-vscode.

diiigle avatar diiigle commented on May 25, 2024

+1

from asciidoctor-vscode.

zoeminghong avatar zoeminghong commented on May 25, 2024

wish

from asciidoctor-vscode.

danyill avatar danyill commented on May 25, 2024

I am super keen for better syncing as well. My coding skills are quite modest but hopefully I can be a research assistant!

See asciidoctor/asciidoctor.js#127

  1. I think we need to run Asciidoctor with sourcemap=true
  2. We then call find_by which returns all nodes
  3. We then iterate across these and call source_location().line_no or similar. We then manipulate the object model to add this information.
  4. @rahmanusta has implemented a TreeProcessor (thanks!) which may be very similar to what is needed here in AsciidocFX which adds the line number to the role.

from asciidoctor-vscode.

joaompinto avatar joaompinto commented on May 25, 2024

@danyill thanks for the research, I was not aware of the sourcemap option.
The markdown built-in extension already provides this functionality (https://github.com/Microsoft/vscode/blob/master/extensions/markdown-language-features/src/markdownEngine.ts#L112) .

I am trying to reuse as much as possible code from the markdown extension, I will see if a similar logic can be implemented from the source_map metatata.

from asciidoctor-vscode.

joaompinto avatar joaompinto commented on May 25, 2024

Metadata is in 9f04dad

I had to look at the AsciidoctorJS source to figure how to use loadFile(), findBy(), getLineNumber(). addRole() .

I need to contribute to improve the documentation from https://github.com/asciidoctor/asciidoctor.js/blob/master/docs/manual.adoc , once this issue gets closed. I am missing the mapping/scroll part in VS Code :)

from asciidoctor-vscode.

joaompinto avatar joaompinto commented on May 25, 2024

I have been looking into markdowns's synchronization code, and from my understanding, it depends on a feature (vscode.window.createWebview) which is only available from the "proposed API", which is restricted to internal VSCode extensions.

Will be tracking microsoft/vscode#28263, hoping that createWebview becomes available for general use.

from asciidoctor-vscode.

joaompinto avatar joaompinto commented on May 25, 2024

After some research I was able to figure a solution for the preview sync with source. Is not perfect but I was the best I could do :P . Those who have the skills please checkout from git, test it, and provide some feedback.

The preview is now "omnidoc", meaning you just need one view for multiple docs,t will get updated depending on the .adoc that is being edited.

The preview is "moved":

  • When text is changed
  • When text is selected

from asciidoctor-vscode.

joaompinto avatar joaompinto commented on May 25, 2024

I am confident on the new code, applied to the newer release.

from asciidoctor-vscode.

danyill avatar danyill commented on May 25, 2024

@joaompinto

I've had a play and it looks good to me. Thanks!

I am interested in making the preview work correctly with Asciidoctor includes at some stage and will raise an issue for this. I'm playing around with some ways to do this.

from asciidoctor-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.