Skip to content

Commit

Permalink
Merge pull request #2 from dseg/GithubFlavouredMarkdown
Browse files Browse the repository at this point in the history
Configurable(On or Off) Github-flavoured markdown rendering mode
  • Loading branch information
hamano committed Jan 22, 2015
2 parents 0dfee1c + b91803a commit 8ad05e2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mod_diary.c
Expand Up @@ -24,6 +24,7 @@
** DiaryPath /path/to/diary
** DiaryTitle Sample Diary
** DiaryURI http://www.example.com/diray/
** DiaryGithubFlavouredMarkdown On
** </Location>
**
** Then after restarting Apache via
Expand Down Expand Up @@ -73,6 +74,7 @@ typedef struct {
const char *theme;
const char *theme_file;
int autolink;
int github_flavoured;
} diary_conf;

static NEOERR *diary_cs_render_cb(void *ctx, char *s)
Expand Down Expand Up @@ -215,6 +217,7 @@ static int diary_handle_entry(request_rec *r,
int size;
char *p;
int flag = 0;
int github_flavoured = conf->github_flavoured;

fp = fopen(filename, "r");
if(fp == NULL){
Expand All @@ -229,7 +232,7 @@ static int diary_handle_entry(request_rec *r,
return HTTP_INTERNAL_SERVER_ERROR;
}
}
doc = mkd_in(fp, 0);
doc = github_flavoured ? gfm_in(fp, 0) : mkd_in(fp, 0);
fclose(fp);
if (doc == NULL) {
return HTTP_INTERNAL_SERVER_ERROR;
Expand Down Expand Up @@ -362,6 +365,7 @@ static void *diary_config(apr_pool_t *p, char *dummy)
c->theme = "default";
c->theme_file = "themes/default/index.cst";
c->autolink = 1;
c->github_flavoured = 0;
return (void *)c;
}

Expand Down Expand Up @@ -405,6 +409,13 @@ static const char *set_diary_autolink(cmd_parms *cmd, void *conf, int flag)
return NULL;
}

static const char *set_diary_github_flavoured(cmd_parms *cmd, void *conf, int flag)
{
diary_conf *c = (diary_conf *)conf;
c->github_flavoured = flag;
return NULL;
}

static const command_rec diary_cmds[] = {
AP_INIT_TAKE1("DiaryPath", set_diary_path, NULL, OR_ALL,
"set DiaryPath"),
Expand All @@ -416,6 +427,9 @@ static const command_rec diary_cmds[] = {
"set DiaryTheme"),
AP_INIT_FLAG("DiaryAutolink", set_diary_autolink, NULL, OR_ALL,
"set autolink with On(default) or Off)"),
AP_INIT_FLAG("DiaryGithubFlavouredMarkdown", set_diary_github_flavoured, NULL, OR_ALL,
"set use of Github-flavoured Markdown with On or Off(default))"),

{NULL}
};

Expand Down

0 comments on commit 8ad05e2

Please sign in to comment.