Gitweb: how to display markdown file in html format automatically like github

前端 未结 4 1945
既然无缘
既然无缘 2021-02-06 01:01

Markdown is important for documentation, it is very nice to see README.md can be automatically show in html format in github like https://github.com/twitter/bootstr

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-06 01:41

    I use following post-receive hook in my remote repositories which are made browsable with gitweb.

    #!/bin/sh
    #
    # Post-receive hook script which generates README.html to git-dir from
    # README.md found at the head of master branch in repository.
    #
    # Gitweb can read the README.html and embed it to the project summary page.
    
    git cat-file blob HEAD:README.md | markdown > $GIT_DIR/README.html
    

    That script is run when I push commits from my local work repositories to the remote bare ones. You could use that or something similar depending on your workflow/setup.

    More information about git hooks: http://book.git-scm.com/5_git_hooks.html

提交回复
热议问题