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

Can you add support for relative paths for images? #9

Open
TomSmartBishop opened this issue Apr 20, 2017 · 5 comments
Open

Can you add support for relative paths for images? #9

TomSmartBishop opened this issue Apr 20, 2017 · 5 comments

Comments

@TomSmartBishop
Copy link
Owner

Issue by elbruno
Sunday May 19, 2013 at 18:31 GMT
Originally opened as lukesdm#10


Hi
something like this

/// <summary>
/// <image url=".\images\sampleCall.png" />
/// </summary>
private VideoChannel videoChannel;

Thanks!
Regards

@TomSmartBishop
Copy link
Owner Author

Comment by lukesdm
Saturday Jun 01, 2013 at 13:32 GMT


Thanks for your suggestion. This should be feasible to implement in a future version.
P.S. I edited your comment for code formatting to get the xml tags to show (you just need to indent each line by 4 spaces).

@TomSmartBishop
Copy link
Owner Author

Comment by Llaves
Tuesday Feb 25, 2014 at 05:05 GMT


Any chance this is going to happen? My build configuration is outside my control, so being able to use a path relative to the source file rather than $(ProjectDir) or an absolute path is very important to me.

@TomSmartBishop
Copy link
Owner Author

Comment by Llaves
Thursday Feb 27, 2014 at 23:17 GMT


Here's a patch to VariableExpander.cs that allows the use of the variable $(CurrentDir) to point to the directory of the document. There's probably a prettier way, but I'm not a C# programmer.

    private const string PROJECTDIR_PATTERN = "$(ProjectDir)";
    private const string SOLUTIONDIR_PATTERN = "$(SolutionDir)";
    private const string CURRENTDIR_PATTERN = "$(CurrentDir)";

....

    private string evaluator(Match match)
    {
        string variableName = match.Value;
        if (string.Compare(variableName, PROJECTDIR_PATTERN, StringComparison.InvariantCultureIgnoreCase) == 0)
        {
            return _projectDirectory;
        }
        else if (string.Compare(variableName, SOLUTIONDIR_PATTERN, StringComparison.InvariantCultureIgnoreCase) == 0)
        {
            return _solutionDirectory;
        }
        else if (string.Compare(variableName, CURRENTDIR_PATTERN, StringComparison.InvariantCultureIgnoreCase) == 0)
        {
          ITextDocument document;
          _view.TextDataModel.DocumentBuffer.Properties.TryGetProperty(typeof(ITextDocument), out document);
          return Path.GetDirectoryName(document.FilePath) + @"\";
        }
        else
        {
            // Could throw an exception here, but it's possible the path contains $(...).
            // TODO: Variable name escaping
            return variableName;
        }
    }

@bjthomson
Copy link

Nice! I actually suggested this on Connect a few years back, but the VS team didn't carry it through. In our current solution, I have a project called DevDocs, and I'll add an images folder there, so hopefully $solutiondir/devdocs/images/thing.png should work.
Agree fixed paths in the file system are less useful.

@Philippe91
Copy link

Following works for relative path:
<image url="$(ItemDir)\doc\foo.png"/>
Though I would prefer the more natural:
<image url=".\doc\foo.png"/>

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

3 participants