From e9be97f4b48cca25422de024fa20c1eff614eff0 Mon Sep 17 00:00:00 2001 From: David Russell Date: Thu, 9 Mar 2017 16:54:22 +0700 Subject: [PATCH] Slide delimiter new defaults and backward compat support. --- app/com/gitpitch/models/MarkdownModel.java | 35 +++++++++++++++++++-- app/com/gitpitch/models/SlideshowModel.java | 10 ++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/app/com/gitpitch/models/MarkdownModel.java b/app/com/gitpitch/models/MarkdownModel.java index 822351b..39fc231 100644 --- a/app/com/gitpitch/models/MarkdownModel.java +++ b/app/com/gitpitch/models/MarkdownModel.java @@ -124,6 +124,8 @@ public class MarkdownModel implements Markdown { YAMLOptions yOpts, String gitRawBase) { + md = processBackwardCompatDelim(md); + if (slideDelimFound(md)) { /* @@ -555,11 +557,40 @@ public class MarkdownModel implements Markdown { return vertDelim() + MD_VSLIDE_GIST; } + /* + * The initial releases of GitPitch used #HSLIDE and #VSLIDE + * as default delimiters. To provide backwards compatability + * for older presentations, when these old delimters are + * detected within PITCHME.md we auto-translate these old + * delimiters to the current defaults HSLIDE|VSLIDE_DELIM_DEFAULT. + */ + private String processBackwardCompatDelim(String md) { + try { + if(md.startsWith(HSLIDE_DELIM_BACK_COMPAT)) { + md = md.replaceFirst(HSLIDE_DELIM_BACK_COMPAT, + HSLIDE_DELIM_DEFAULT); + } else + if(md.startsWith(VSLIDE_DELIM_BACK_COMPAT)) { + md = md.replaceFirst(VSLIDE_DELIM_BACK_COMPAT, + VSLIDE_DELIM_DEFAULT); + } + + } catch(Exception bcex) { + return md; + } + return md; + } + /* * Markdown Parsing Identifiers | Delimiters. */ - public static final String HSLIDE_DELIM_DEFAULT = "#HSLIDE"; - public static final String VSLIDE_DELIM_DEFAULT = "#VSLIDE"; + public static final String HSLIDE_DELIM_DEFAULT = "---"; + public static final String VSLIDE_DELIM_DEFAULT = "+++"; + public static final String HSLIDE_REGEX_DEFAULT = null; + public static final String VSLIDE_REGEX_DEFAULT = "\\+\\+\\+"; + + public static final String HSLIDE_DELIM_BACK_COMPAT = "#HSLIDE"; + public static final String VSLIDE_DELIM_BACK_COMPAT = "#VSLIDE"; public static final String MD_LINK_OPEN = "!["; public static final String MD_IMAGE_OPEN = diff --git a/app/com/gitpitch/models/SlideshowModel.java b/app/com/gitpitch/models/SlideshowModel.java index 1bcce5c..4e26ac9 100644 --- a/app/com/gitpitch/models/SlideshowModel.java +++ b/app/com/gitpitch/models/SlideshowModel.java @@ -380,7 +380,10 @@ public class SlideshowModel { } if(delim == null) { - delim = buildSlideDelim(MarkdownModel.HSLIDE_DELIM_DEFAULT); + if(MarkdownModel.HSLIDE_REGEX_DEFAULT != null) + delim = buildSlideDelim(MarkdownModel.HSLIDE_REGEX_DEFAULT); + else + delim = buildSlideDelim(MarkdownModel.HSLIDE_DELIM_DEFAULT); } return delim; } @@ -399,7 +402,10 @@ public class SlideshowModel { } if(delim == null) { - delim = buildSlideDelim(MarkdownModel.VSLIDE_DELIM_DEFAULT); + if(MarkdownModel.VSLIDE_REGEX_DEFAULT != null) + delim = buildSlideDelim(MarkdownModel.VSLIDE_REGEX_DEFAULT); + else + delim = buildSlideDelim(MarkdownModel.VSLIDE_DELIM_DEFAULT); } return delim; }