Beispiel #1
0
        public static string Markdownify(string s, MarkdownExtensions extensions = MarkdownExtensions.None, bool smartypants = true)
        {
#endif
            mkd_renderer renderer = new mkd_renderer();

            buf input;
            input.data  = s;
            input.size  = (uint)s.Length;
            input.asize = (uint)Math.Max(1024, s.Length);
            input.unit  = 1024;
            input.@ref  = 1;

            IntPtr poutput = bufnew(64);

            sdhtml_renderer(ref renderer, (uint)0);
            sd_markdown(poutput, ref input, ref renderer, (uint)extensions);
            sdhtml_free_renderer(ref renderer);

            buf output;

            if (smartypants)
            {
                IntPtr psmarty = bufnew(128);
                sdhtml_smartypants(psmarty, poutput);
                output = (buf)Marshal.PtrToStructure(psmarty, typeof(buf));
                bufrelease(psmarty);
            }
            else
            {
                output = (buf)Marshal.PtrToStructure(poutput, typeof(buf));
            }

            bufrelease(poutput);

            string result = String.Empty;

            if (output.data != null)
            {
                result = output.data.Substring(0, (int)output.size);
            }

            return(result);
        }
Beispiel #2
0
 private static extern void sdhtml_free_renderer(ref mkd_renderer renderer);
Beispiel #3
0
 private static extern void sd_markdown(IntPtr ob, ref buf ib, ref mkd_renderer renderer, uint extensions);
Beispiel #4
0
 private static extern void sdhtml_renderer(ref mkd_renderer renderer, uint render_flags);
Beispiel #5
0
        public static string Markdownify(string s, MarkdownExtensions extensions = MarkdownExtensions.None, bool smartypants = true) {
#endif
            mkd_renderer renderer = new mkd_renderer();

            buf input;
            input.data = s;
            input.size = (uint)s.Length;
            input.asize = (uint)Math.Max(1024, s.Length);
            input.unit = 1024;
            input.@ref = 1;
            
            IntPtr poutput = bufnew(64);

            sdhtml_renderer(ref renderer, (uint)0);
            sd_markdown(poutput, ref input, ref renderer, (uint)extensions);
            sdhtml_free_renderer(ref renderer);

            buf output;

            if (smartypants) {
                IntPtr psmarty = bufnew(128);
                sdhtml_smartypants(psmarty, poutput);
                output = (buf)Marshal.PtrToStructure(psmarty, typeof(buf));
                bufrelease(psmarty);
            } else {
                output = (buf)Marshal.PtrToStructure(poutput, typeof(buf));
            }

            bufrelease(poutput);

            string result = String.Empty;

            if (output.data != null)
                result = output.data.Substring(0, (int)output.size);

            return result;
                
        }
Beispiel #6
0
 private static extern void sd_markdown(IntPtr ob, ref buf ib, ref mkd_renderer renderer, uint extensions);
Beispiel #7
0
 private static extern void sdhtml_free_renderer(ref mkd_renderer renderer);
Beispiel #8
0
 private static extern void sdhtml_renderer(ref mkd_renderer renderer, uint render_flags);