Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use with .rst files #25

Open
ubmarco opened this issue May 12, 2020 · 3 comments
Open

Use with .rst files #25

ubmarco opened this issue May 12, 2020 · 3 comments

Comments

@ubmarco
Copy link
Contributor

ubmarco commented May 12, 2020

Thanks a lot for this extension, it has proven very useful to me.

I use Plantuml in Sphinx with the sphinxcontrib.plantuml extension. In below RST file, plantuml-previewer.vim basically works, but will only render the first diagram.

Chapter1
--------

.. uml::

  @startuml
  class test1
  @enduml


Chapter2
--------

.. uml::

  @startuml
  class test2
  @enduml

I guess it looks for the first @startuml. I would appreciate a feature where plantuml-previewer.vim is aware of the cursor location and will look for surrounding @startuml and @enduml appearances. If none are found, it can default to the current implementation. The automatic update mechanism would have to somehow remember the Plantuml instance and update accordingly if it gets changed. This would also bind the browser page to a certain diagram.

Do you think that's feasible? Do you see a workaround in the current implementation?

@weirongxu
Copy link
Owner

Perhaps we can provide a lower-level API, then can let users use text to preview the plantuml.

Example:

let start = searchpairpos('@startuml', '', '@enduml', 'nb')
let end = searchpairpos('@startuml', '', '@enduml', 'n')
call plantuml_preview#refresh_by_content(getline(start, end), 'foo.puml')

@ubmarco
Copy link
Contributor Author

ubmarco commented May 12, 2020

Thanks for the fast response, this sounds like a great idea.
I commonly have RST files with many PUML diagrams. Can the refresh_by_content function find out if the relevant files have changed so rendering is not triggered if all lines are identical? That would reduce load/render times a lot.
One note on above code, the function searchpairpos returns a list [line-numer, column], so I guess getline(start[0], end[0]) is needed.

@weirongxu
Copy link
Owner

Can the refresh_by_content function find out if the relevant files have changed so rendering is not triggered if all lines are identical?

I agree with you

I guess getline(start[0], end[0]) is needed.

Indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants