ukarim / ngx_markdown_filter_module

Markdown-to-html nginx module
MIT License
18 stars 3 forks source link

This module will not completely trnaform the whole marddown file. #2

Closed sousukerai closed 1 year ago

sousukerai commented 1 year ago

Compiled successfully into nginx, run it and it will stop transform the whole markdown file into html format. my nginx.conf is as follows,

user nobody;

worker_processes 1;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

pid logs/nginx.pid;

events { worker_connections 2048; # original 1024 }

http { include mime.types; default_type application/octet-stream;

charset utf-8;

# try to correct ngx_markdown_filter_module
client_max_body_size 100M;
# Set the buffer size for reading client request body
client_body_buffer_size 10M;
# Set the buffer size for reading from the upstream server
proxy_buffer_size 64k;
# Set the number and size of buffers used for reading from the upstream server
proxy_buffers 8 64k;
# Set the size of the buffer used for reading from the upstream server when the connection is busy
proxy_busy_buffers_size 128k;
# Set the timeout for reading from the upstream server
proxy_read_timeout 300s;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

server {
    listen       8888;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   html;
        index  index.html index.htm;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
    }

    # Render Markdown files as HTML pages using ngx_http_markdown_filter_module
    location ~ \.md$ {
        add_header Content-Type 'text/html';
        markdown_filter on;
        markdown_template /usr/local/nginx/html/template.html;
        # markdown_template html/template.html;
        # sub_filter_types *;
        # sub_filter '</body>' '<div style="padding: 20px;">$markdown$</div></body>';
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

# HTTPS server
#
#server {
#    listen       443 ssl;
#    server_name  localhost;

#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers  on;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

}

ukarim commented 1 year ago

@sousukerai Hi, try to add 'sendfile off' next to the markdown directives. Also, can you please share the problematic markdown file (if it possible)

ukarim commented 1 year ago

@sousukerai it is a bug I've introduced in last commit. Reverted it. You can rebuild the module using latest commit from master. Thank you!

sousukerai commented 1 year ago

I rebuilt the nginx-1.24.0 with your tag 0.1.1, then it will render the whole markdown page very well. Thanks. The other issue is markdown table which I used often. The table is still not be rendered right. For which I could live with. Again, thanks for your effort and a very wonderful work!

ukarim commented 1 year ago

@sousukerai thanks for your kind words! Unfortunately, original cmark lib doesn't support syntax for tables. I've commited support for cmark-gfm lib (fork by Github with support for tables)