You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Bo Berglund <bo...@gmail.com> on 2022/01/12 21:15:23 UTC

[users@httpd] How to configure and use mod_markdown

Ubuntu server 20.04.3 Apache2
I am trying to install support for rendering files with extension .md so they
are displayed like for example md files in GitHub.
I have a lot of md documents, which I need to view regularly and it would be so
much easier if Apache could do this.

So I have asked on Ubuntu User mail list and got directed to this module on
GitHub:
https://github.com/hamano/apache-mod-markdown

I have checked out on trunk and performed the steps in README.md to build and
deposit the module file here (I had to work around deficiencies in documentation
but finally got there):

/usr/lib/apache2/modules/mod_markdown.so

Now I would like to get some help in going forward, since the documentation for
this addon is not "for dummies" like myself...

Which apache config files do I need to edit to get this going?

I am OK to begin with to use the default Apache website as the test environment,
but I have no idea how to make that happen.

This is what is printed in the README.md file:

Configuration

in httpd.conf: <== should this be /etc/apache2/apache2.conf ???

LoadModule markdown_module /usr/lib/apache2/modules/mod_markdown.so   <== Were
in the file does this go???

<Location />   <== Is this in another file in sites-available?
    AddHandler markdown .md

    # If you want to use stylesheet.
    # MarkdownCss style.css
    # MarkdownHeader "<p>Header</p>"
    # MarkdownFooter "<p>Footer</p>"
</Location>

Or:

<Directory /var/www>  <== Again which file does it go into? 000-default.conf??
    AddHandler markdown .md
    DirectoryIndex index.md
</Directory>

What else needs to be done to make it work?


-- 
Bo Berglund
Developer in Sweden


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: How to configure and use mod_markdown

Posted by Bo Berglund <bo...@gmail.com>.
On Thu, 13 Jan 2022 15:00:12 -0500, Eric Covener <co...@gmail.com> wrote:

>> But if I put the md file on my webserver (without having thios server side
>> parsing) then I expected the add-on to again render the file into a html and
>> display it. But that does not happen at all, FireFox just opens a dialog to ask
>> me with what to open the file?
>
>
>Maybe something like this makes the extension happy: AddType text/plain .md

Where exactly do you mean I should AddType?
In FirefFox settings somewhere?

Meanwhile:

I have investigated the FFx AddOn usage more now and it turns out that I can
make the add-on be engaged when loading an url with an md file ending:

- First I have to switch off mod-markdown on the server
- Next I use the URL to the md file in FireFox
- Now FFx shows a dialog on how to do, select open with FireFox
- Also set this as the default action

Now when it is fed such an URL it first displays the raw text for a little
while, then it switches to the rendered view and the address bar now shows a
file system URL like: file:///C:/Users/Bosse/AppData/Local/Temp/Bosse2-2.md

So FireFox actually saves the received data to a text file in Temp and the
Add-On reads the data and then it creates a converted version to show...

Impossible to bookmark such md files because when it is all done the URL points
to the local file system.


-- 
Bo Berglund
Developer in Sweden


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Re: How to configure and use mod_markdown

Posted by Eric Covener <co...@gmail.com>.
> But if I put the md file on my webserver (without having thios server side
> parsing) then I expected the add-on to again render the file into a html and
> display it. But that does not happen at all, FireFox just opens a dialog to ask
> me with what to open the file?


Maybe something like this makes the extension happy: AddType text/plain .md

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Re: How to configure and use mod_markdown

Posted by Eric Covener <co...@gmail.com>.
> Is there some alternative around?

If you don't care about performance and want flexibility you can roll
your own with CGI.

httpd.conf:

AddHandler md2html .md
Action md2html /cgi-bin/md2html

cgi:
```
#!/bin/sh

printf "Content-Type: text/html\r\n\r\n"


if [ -f "$PATH_TRANSLATED" ]; then
  pandoc -t html5  $PATH_TRANSLATED
fi
```

Then you can put whatever extra logic prior to invoking pandoc to add
head or style elements.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: How to configure and use mod_markdown

Posted by Bo Berglund <bo...@gmail.com>.
On Thu, 13 Jan 2022 12:15:54 -0500, Eric Covener <co...@gmail.com> wrote:

>>     MarkdownCss /opt/misc/apache-mod-markdown/markdown.css
>
>From the code you linked to, this seems like it would pretend to work
>if you ran it locally in a browser on the webserver.
>The content of the CSS file is not incorporated into the output, only
>a meta tag with the path verbatim that would not work non-local.

I have the basics running with the document-root relative path for the css file.
So my question was really solved by testing, I am just wondering if both are
allowed because it seems like Apache would have a problem then deciding which to
use...

I have another problem now and that is the following:

When using FirFox with the Markdown Viewer Webext add-on I can only ever view md
files if they are local. I.e. Firefox opens an url like this:
file:///D:/Docs/Linuxstuff/LinuxCommands.md

Then the add-on thinks for a good time (depending on file size) and then renders
the page OK. It seems like it converts to html somewhere on my disk and then
opens that.

But if I put the md file on my webserver (without having thios server side
parsing) then I expected the add-on to again render the file into a html and
display it. But that does not happen at all, FireFox just opens a dialog to ask
me with what to open the file?
Obviously, the AddOn is not among what I can select from so it tries to save to
disk instead.

So I need to get the  server side working and I have gotten it *almost* working,
but in fact it fails in many places inside the docuemnt.
Whenever there is a code section it is hit or miss if it will understand it,
sometimes it just displays the 3 ticks and then the whole code mass as a single
block of text without formatting...

I wonder if the https://github.com/hamano/apache-mod-markdown code is really
working fully?
It seems to have big problems.

Is there some alternative around?

-- 
Bo Berglund
Developer in Sweden


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Re: How to configure and use mod_markdown

Posted by Eric Covener <co...@gmail.com>.
>     MarkdownCss /opt/misc/apache-mod-markdown/markdown.css

From the code you linked to, this seems like it would pretend to work
if you ran it locally in a browser on the webserver.
The content of the CSS file is not incorporated into the output, only
a meta tag with the path verbatim that would not work non-local.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: How to configure and use mod_markdown

Posted by Bo Berglund <bo...@gmail.com>.
On Wed, 12 Jan 2022 22:15:23 +0100, Bo Berglund <bo...@gmail.com> wrote:

>Ubuntu server 20.04.3 Apache2
>I am trying to install support for rendering files with extension .md so they
>are displayed like for example md files in GitHub.
>
>So I have asked on Ubuntu User mail list and got directed to this module on
>GitHub:
>https://github.com/hamano/apache-mod-markdown
>
>I have checked out on trunk and performed the steps in README.md to build and
>deposit the module file here (I had to work around deficiencies in documentation
>but finally got there):
>
>/usr/lib/apache2/modules/mod_markdown.so
>

I have been able to get it going but I have a question regarding which paths to
use inside the site configuration files:

In the file /etc/apache2/sites-available/000-default.conf I have added this:

    AddHandler markdown .md
    # If you want to use stylesheet.
    MarkdownCss /styles/markdown.css

The path here refers to the site documentroot AFAICT and it works if I put the
css file in a document root subdir "styles"

But I have read other documentation that uses an absolute file system path in
this case instead:

    MarkdownCss /opt/misc/apache-mod-markdown/markdown.css

This looks like it could be a way to use the same css file on several sites
using markdown without duplication..

What is the real deal here? Are paths in these files possible to be both
documentroot relative and absolute file system paths?
Which should be used?
And how does apache differentiate between them?


-- 
Bo Berglund
Developer in Sweden


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org