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

Respect imagesdir when resolving image paths in source file #275

Closed
alshain opened this issue Jun 18, 2019 · 7 comments
Closed

Respect imagesdir when resolving image paths in source file #275

alshain opened this issue Jun 18, 2019 · 7 comments

Comments

@alshain
Copy link

alshain commented Jun 18, 2019

When typing images:: and invoking auto-complete, completions are provided seem to be based on the current file's directory.

However, using imagesdir: ./img for example at the top of the file, those paths are relative to a subdirectory, which neither the auto completion nor the ctrl-click thing processes correctly.

return new FileReferenceSet(bodyNode.getText(), this, bodyNode.getStartOffset() - getTextRange().getStartOffset(),

I'm guessing here one would need to detect 1) that an image path is being processed 2) the imagesdir thing is used and make use of a PsiReferencesProvider.

This would probably solve both things, as well as allow IntelliJ to automatically update the image paths when renaming files.

#253

@alshain
Copy link
Author

alshain commented Jun 18, 2019

Maybe I can take a look at the PsireferencesProvider bit later this week.

@ahus1
Copy link
Contributor

ahus1 commented Jun 18, 2019

@alshain - I look forward to see a solution here! Please note: variables (like :xx:) currently have only lexer and highlighting support, but no Parser/Named Element support at the moment.

Let me know if you want to tackle this as well, or if you want that to be solved before.

@ahus1
Copy link
Contributor

ahus1 commented Jun 23, 2019

@alshain - attributes now have PSI and names element support as part of #243; this might help a bit here.

@ahus1 ahus1 self-assigned this Jul 11, 2019
@ahus1
Copy link
Contributor

ahus1 commented Jul 11, 2019

I'm starting working on this. Current plan: replace FileReferenceSet in AsciiDocBlockMacro with my own implementation to resolve variables in general and taking into account imagesDir for all image::[].

@ahus1
Copy link
Contributor

ahus1 commented Jul 12, 2019

The preview release 0.28.15 now resolves attributes in macros, supports ".." and respects the imagesDir for images macros. It also supports inline macros (previously only block macros were supported).

As part of the suggested completions also shows ".." and all attributes that resolve to an existing file or directory. Attributes are shown in the list with the resolved value.

You can navigate using Ctrl+Click and Ctrl+B to each of part of the path.

As of today the discovery of attributes in a compact definition like this

ifndef::imagesdir[:imagesdir: ../images]

is not supported in the lexer/paser, please use the longer variant

ifndef::imagesdir[]
:imagesdir: ../images
endif::[]

@ahus1
Copy link
Contributor

ahus1 commented Jul 12, 2019

please comment here with

  • corner cases that I might have missed
  • ideas on how to restrict the list of auto-complete elements to relevant file types and/or directories depending on the macro name
  • additions to the macro names that accept files in their body. As of today this allows for "image", "include", "video" and "audio" plus asciidoctor diagram types.

ahus1 added a commit that referenced this issue Jul 12, 2019
@ahus1
Copy link
Contributor

ahus1 commented Jul 19, 2019

This is in available in the latest public release of the plugin (0.28.17+) in the regular channel.

@ahus1 ahus1 closed this as completed Jul 19, 2019
ahus1 added a commit to ahus1/asciidoctor-intellij-plugin that referenced this issue Jul 31, 2019
ahus1 added a commit to ahus1/asciidoctor-intellij-plugin that referenced this issue Jul 31, 2019
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