rosscdh / mkdocs-markdownextradata-plugin

A MkDocs plugin that injects the mkdocs.yml extra variables into the markdown template
MIT License
83 stars 18 forks source link

Macro in included page #7

Closed xtran3 closed 5 years ago

xtran3 commented 5 years ago

Could someone help me on this issue?

I have project structure like this:

mkdocs.yml file:

...
extra:
  site:
    image_path: 'http://abc/images/'
plugins:
  - search
  - git-revision-date
  - macros
  - markdownextradata
...

Showcase.md content:

{!Showcase/Cases/Case1.md!}

Case1.md content:

![SampleImage]({{ site.image_path }}image1.PNG)

If I go to http://abc/Showcase/Cases/Case1, then I can see the image1.PNG. The real url is http://abc/images/image1.PNG. But if I go to http://abc/Showcase/Cases, the image load failed. I check the HTML source: <img alt="SampleImage" src="{{ site.image_path }}image1.PNG"> The {{ site.image_path }} is not generated! It seems like the macro does not work when using "include" page in .md

Could you please help to verify this?

rosscdh commented 5 years ago

You may need to provide more info

site_name: My Docs
nav:
    - Home: index.md
extra:
  site:
    image_path: https://via.placeholder.com/
plugins:
  - search
  - markdownextradata
# Welcome to MkDocs

For full documentation visit [mkdocs.org](https://mkdocs.org).

## Image test

![SampleImage]({{ site.image_path }}350x150)
Screen Shot 2019-04-12 at 21 06 29

Seems to work jsut fine..

I am ot using your macro plugins etc.. so please provide a full example for that?

rosscdh commented 5 years ago

Given that the issue appears to lie with the macros plugin? (seems to) perhaps best to lodge a ticket with them? Ill take a look as well.. but it appears to work on my side?

rosscdh commented 5 years ago

Now rereading the text in the bug.. yes using include does not run the internal text thought the mdocs parser so wont actually render the variables used within.

rosscdh commented 5 years ago

if you can provide the code you are using to generate the http://abc/Showcase/Cases page i can help you out

xtran3 commented 5 years ago

Hi @rosscdh ,

Thanks for your time look into my issue.

This is the code for the relating part: WMAI.github.dxc.com.zip

The image in here works fine: https://github.dxc.com/pages/WMAI/Showcase/Intune_Modern_Management/Intune_Demo_Overview/ The image's link here is not generated: https://github.dxc.com/pages/WMAI/Showcase/Showcase/

xtran3 commented 5 years ago

Do you have any updates on this @rosscdh ?

rosscdh commented 5 years ago

Sorry no its Easter Holidays at the moment. Perhaps later next week!

On Fri, Apr 19, 2019 at 4:36 AM Xuan Tran notifications@github.com wrote:

Do you have any updates on this @rosscdh https://github.com/rosscdh ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rosscdh/mkdocs-markdownextradata-plugin/issues/7#issuecomment-484749109, or mute the thread https://github.com/notifications/unsubscribe-auth/AADA6MSYVHMGVXQDSQWOINTPREV3JANCNFSM4HFOAHQA .

rosscdh commented 5 years ago

Hmm just took a look..

have you debugged the output of the image?

http head https://github.dxc.com/pages/WMAI/images/modernmanagement/ModernDeviceManagement.PNG            rosscdh@s
HTTP/1.1 302 Found
Cache-Control: no-cache
Content-Security-Policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; connect-src 'self' github.dxc.com www.githubstatus.com wss://github.dxc.com; font-src 'self'; form-action 'self' github.dxc.com; frame-ancestors 'none'; frame-src 'self'; img-src * data:; manifest-src 'self'; media-src 'none'; script-src 'self'; style-src 'unsafe-inline' 'self'

gives 302 looks like some kind of security... the image does not exist which is why its not being shown.

ive tried it with an existing image..... and it appears to work as expected.. there is something wrong with the image you are trying to reference....

Screen_Shot_2019-04-19_at_18_20_48
rosscdh commented 5 years ago

closing the issue

xtran3 commented 5 years ago

Hi,

Why do you close the ticket so soon? :)

You cannot see the image because you don't have permission to view it. I logged in and I can see the image at https://github.dxc.com/pages/WMAI/images/modernmanagement/ModernDeviceManagement.PNG image

This is my issue on the including page: image

While the included page work well: image

Could you please share the source code of the page you are showing? Could you please share the link of the page so I can inspect the HTML source? Does your working image using macro? I would be great if you can share back to me the page you are demoing?

Many thanks

rosscdh commented 5 years ago

Hi all i did was take in your macro page and link to an image in the public space.. try use another image from somewhere else.

I tested using the same structure u provided and seemed to work both as in a macro include and as loading the page directly.

On Mon, 22 Apr 2019, 05:36 Xuan Tran, notifications@github.com wrote:

Hi,

Why do you close the ticket so soon? :)

You cannot see the image because you don't have permission to view it. I logged in and I can see the image at https://github.dxc.com/pages/WMAI/images/modernmanagement/ModernDeviceManagement.PNG [image: image] https://user-images.githubusercontent.com/3803024/56481176-eee94a00-64e7-11e9-9d31-c6e18eaf7bd3.png

This is my issue: [image: image] https://user-images.githubusercontent.com/3803024/56481672-691ace00-64ea-11e9-8e02-c130b45a4342.png

Could you please share the source code of the page you are showing? Could you please share the link of the page so I can inspect the HTML source? Does your working image using macro? I would be great if you can share back to me the page you are demoing?

Many thanks

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/rosscdh/mkdocs-markdownextradata-plugin/issues/7#issuecomment-485314802, or mute the thread https://github.com/notifications/unsubscribe-auth/AADA6MVKVC5BQYSJZTI7ZN3PRUXCHANCNFSM4HFOAHQA .

rosscdh commented 5 years ago

working-Archive.zip

There you go, a couple of tips

  1. its yaml you dont and indeed SHOULDNT wrap all your image references in `` or '' this has a specific case and you should study when to use this
  2. your paths should not end on a / in yaml.. its better to include the / in the path ie.. {{ site.image_path }}/whatever.PNG
  3. ALWAYS lowercase filenames
  4. image_path is actually a bad name its not a path its a image_base_url a path is the /path/to/file.png
  5. look for test_path in the modern showcase

best of luck

rosscdh commented 5 years ago

please note as per your last set of provision.. the pluging that does not seem to be working for you is the "macros" plugin please raise it with the maintainer.

xtran3 commented 5 years ago

Hi, Much appreciate that you response to me promptly while you are in holiday vacation. I will try your recommendation.

xtran3 commented 5 years ago

I tried the package you gave me and built on local. I got this error: image

And this is the HTML source: image

On local, I run these commands:

            python -m pip install --upgrade --ignore-installed pip
            pip --version
            pip install mkdocs
            pip install mkdocs-material
            pip install markdown-include
            pip install mkdocs-macros-plugin
            pip install mkdocs-git-revision-date-plugin
            pip install mkdocs-markdownextradata-plugin

then run "mkdocs build" Am I correct?

rosscdh commented 5 years ago

did you add the test_path variabel to the site block in the extras in mkdocks.yml

you can see the screenshots that its working thus its something on your end.

On Wed, Apr 24, 2019 at 6:33 AM Xuan Tran notifications@github.com wrote:

I tried the package you gave me and built on local. I got this error: [image: image] https://user-images.githubusercontent.com/3803024/56632407-d31aab00-6683-11e9-89a8-0d04e3c9e0ee.png

And this is the HTML source: [image: image] https://user-images.githubusercontent.com/3803024/56632566-97ccac00-6684-11e9-93ca-7424ab031527.png

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/rosscdh/mkdocs-markdownextradata-plugin/issues/7#issuecomment-486063812, or mute the thread https://github.com/notifications/unsubscribe-auth/AADA6MVFOWETGDCWYBCNIFDPR7PHXANCNFSM4HFOAHQA .

rosscdh commented 5 years ago

On build i also get that its simply trying to refer to a image that it expects to exist locally. it does not exist locally obviously its a remote image. Can be ignored.

On Wed, Apr 24, 2019 at 7:38 AM Ross sendrossemail@gmail.com wrote:

did you add the test_path variabel to the site block in the extras in mkdocks.yml

you can see the screenshots that its working thus its something on your end.

On Wed, Apr 24, 2019 at 6:33 AM Xuan Tran notifications@github.com wrote:

I tried the package you gave me and built on local. I got this error: [image: image] https://user-images.githubusercontent.com/3803024/56632407-d31aab00-6683-11e9-89a8-0d04e3c9e0ee.png

And this is the HTML source: [image: image] https://user-images.githubusercontent.com/3803024/56632566-97ccac00-6684-11e9-93ca-7424ab031527.png

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/rosscdh/mkdocs-markdownextradata-plugin/issues/7#issuecomment-486063812, or mute the thread https://github.com/notifications/unsubscribe-auth/AADA6MVFOWETGDCWYBCNIFDPR7PHXANCNFSM4HFOAHQA .

xtran3 commented 5 years ago

as you can see the build log: the test_path is in mkdocs.yml image

xtran3 commented 5 years ago

And this is the built result \site\Showcase\Showcase\index.html


<p><img alt="ModernDeviceManagement" src="{{ site.image_path }}modernmanagement/ModernDeviceManagement.PNG" /></p>
<p><img alt="ModernDeviceManagement" src="{{ site.test_path }}/funny-game-of-thrones-memes-fb__700.jpg" /></p>
rosscdh commented 5 years ago

Yes because build is trying to find that reference locally (mkdocs assumes all images are local)

as I said feel free to create a PR for mkdocs on the topic

On Wed, Apr 24, 2019 at 11:04 AM Xuan Tran notifications@github.com wrote:

And this is the built result \site\Showcase\Showcase\index.html

ModernDeviceManagement

ModernDeviceManagement

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/rosscdh/mkdocs-markdownextradata-plugin/issues/7#issuecomment-486135129, or mute the thread https://github.com/notifications/unsubscribe-auth/AADA6MXXUUJA4JDNBLYOMBDPSAPBHANCNFSM4HFOAHQA .

cesaremorel commented 5 years ago

I think issue has to be reopen cause focus is wrong.

Problem can replicate when you try to get macros plugin and markdown-include extension (or whatever using jinja2) work together.

It doesn matter if you use an URL (pointing to web or to an image) or a simple string.

cipacda commented 5 years ago

I agree with @cesaremorel , this issue can be replicated with any value that you want to replace in a markdown partial. I think this should be reopen.

rosscdh commented 5 years ago

Hey there please feel free to open a pr

On Thu, 25 Jul 2019, 17:07 Ciprian Florescu, notifications@github.com wrote:

I agree with @cesaremorel https://github.com/cesaremorel , this issue can be replicated with any value that you want to replace in a markdown partial. I think this should be reopen.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/rosscdh/mkdocs-markdownextradata-plugin/issues/7?email_source=notifications&email_token=AADA6MT6EY3XZJPRHFM54C3QBG6R7A5CNFSM4HFOAHQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2ZYTLA#issuecomment-515082668, or mute the thread https://github.com/notifications/unsubscribe-auth/AADA6MRQIJSGCERUTIBKXODQBG6R7ANCNFSM4HFOAHQA .