Пример #1
0
        public static string MakeText(string markdown, ConverterHooksConfig converterHooksConfig)
        {
            var transformContext = MarkdownTransformContext.ForText();

            var html = MarkdownService.MakeHtmlInternal(markdown, converterHooksConfig, transformContext);

            var stripped = GetDocumentText(html);
            return stripped;
        }
        public AssetsWikiDownJsViewModel(ConverterHooksConfig converterHooksConfig, WikiDownConfig config)
        {
            if (converterHooksConfig == null)
            {
                throw new ArgumentNullException("converterHooksConfig");
            }

            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            this.config = config;

            PreConversionHookRules = GetConversionHookRules(converterHooksConfig.PreConversionHooks);
            PostConversionHookRules = GetConversionHookRules(converterHooksConfig.PostConversionHooks);
        }
Пример #3
0
        internal static string MakeHtmlInternal(
            string markdown,
            ConverterHooksConfig config,
            MarkdownTransformContext context)
        {
            if (markdown == null)
            {
                throw new ArgumentNullException("markdown");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            string lineBreakedMarkdown = LinebreaksRegex.Replace(markdown, LinebreaksReplace);

            string beforePreConversionsMarkdown = context.ApplyBeforePreConversions(lineBreakedMarkdown) ?? string.Empty;

            string preConversionMarkdown = config.ApplyPreConversions(beforePreConversionsMarkdown) ?? string.Empty;

            string afterPreConversionsMarkdown = context.ApplyAfterPreConversions(preConversionMarkdown) ?? string.Empty;

            string transformedHtml = MarkdownConverter.Transform(afterPreConversionsMarkdown) ?? string.Empty;

            string beforePostConversionHtml = context.ApplyBeforePostConversions(transformedHtml) ?? string.Empty;

            string postConversionHtml = config.ApplyPostConversions(beforePostConversionHtml) ?? string.Empty;

            string afterPostConversionHtml = context.ApplyAfterPostConversions(postConversionHtml) ?? string.Empty;

            string trimmedConversionHtml = afterPostConversionHtml.Trim();
            return trimmedConversionHtml;
        }
Пример #4
0
        public static string MakeHtml(string markdown, ConverterHooksConfig converterHooksConfig)
        {
            var transformContext = MarkdownTransformContext.ForHtml();

            return MakeHtmlInternal(markdown, converterHooksConfig, transformContext);
        }
 public AssetsWikiDownJsViewModel(ConverterHooksConfig converterHooksConfig)
     : this(converterHooksConfig, WikiDownConfig.Instance)
 {
 }