diff --git a/baseelement.go b/baseelement.go index 5f42440..4ea8fc6 100644 --- a/baseelement.go +++ b/baseelement.go @@ -146,15 +146,15 @@ func (e *BaseElement) Render(w io.Writer, ctx RenderContext) error { rules := bs.With(e.Style) // render unstyled prefix/suffix - renderText(w, bs.Current().Style.StylePrimitive, rules.Prefix) + renderText(w, bs.Current().Style.StylePrimitive, rules.BlockPrefix) defer func() { - renderText(w, bs.Current().Style.StylePrimitive, rules.Suffix) + renderText(w, bs.Current().Style.StylePrimitive, rules.BlockSuffix) }() // render styled prefix/suffix - renderText(w, rules, rules.StyledPrefix) + renderText(w, rules, rules.Prefix) defer func() { - renderText(w, rules, rules.StyledSuffix) + renderText(w, rules, rules.Suffix) }() s := e.Token diff --git a/blockelement.go b/blockelement.go index ec0cc3c..49b87e7 100644 --- a/blockelement.go +++ b/blockelement.go @@ -18,8 +18,8 @@ func (e *BlockElement) Render(w io.Writer, ctx RenderContext) error { bs := ctx.blockStack bs.Push(*e) - renderText(w, bs.Parent().Style.StylePrimitive, e.Style.Prefix) - renderText(bs.Current().Block, bs.Current().Style.StylePrimitive, e.Style.StyledPrefix) + renderText(w, bs.Parent().Style.StylePrimitive, e.Style.BlockPrefix) + renderText(bs.Current().Block, bs.Current().Style.StylePrimitive, e.Style.Prefix) return nil } @@ -47,8 +47,8 @@ func (e *BlockElement) Finish(w io.Writer, ctx RenderContext) error { } } - renderText(w, bs.Current().Style.StylePrimitive, e.Style.StyledSuffix) - renderText(w, bs.Parent().Style.StylePrimitive, e.Style.Suffix) + renderText(w, bs.Current().Style.StylePrimitive, e.Style.Suffix) + renderText(w, bs.Parent().Style.StylePrimitive, e.Style.BlockSuffix) bs.Current().Block.Reset() bs.Pop() diff --git a/codeblock.go b/codeblock.go index 88f273b..76054be 100644 --- a/codeblock.go +++ b/codeblock.go @@ -36,9 +36,9 @@ func (e *CodeBlockElement) Render(w io.Writer, ctx RenderContext) error { } if len(theme) > 0 { - renderText(iw, bs.Current().Style.StylePrimitive, rules.Prefix) + renderText(iw, bs.Current().Style.StylePrimitive, rules.BlockPrefix) err := quick.Highlight(iw, e.Code, e.Language, "terminal16m", theme) - renderText(iw, bs.Current().Style.StylePrimitive, rules.Suffix) + renderText(iw, bs.Current().Style.StylePrimitive, rules.BlockSuffix) return err } diff --git a/heading.go b/heading.go index ed7066d..72f4afb 100644 --- a/heading.go +++ b/heading.go @@ -41,8 +41,8 @@ func (e *HeadingElement) Render(w io.Writer, ctx RenderContext) error { } bs.Push(be) - renderText(w, bs.Parent().Style.StylePrimitive, rules.Prefix) - renderText(bs.Current().Block, bs.Current().Style.StylePrimitive, rules.StyledPrefix) + renderText(w, bs.Parent().Style.StylePrimitive, rules.BlockPrefix) + renderText(bs.Current().Block, bs.Current().Style.StylePrimitive, rules.Prefix) return nil } @@ -81,8 +81,8 @@ func (e *HeadingElement) Finish(w io.Writer, ctx RenderContext) error { return err } - renderText(w, bs.Current().Style.StylePrimitive, rules.StyledSuffix) - renderText(w, bs.Parent().Style.StylePrimitive, rules.Suffix) + renderText(w, bs.Current().Style.StylePrimitive, rules.Suffix) + renderText(w, bs.Parent().Style.StylePrimitive, rules.BlockSuffix) bs.Current().Block.Reset() bs.Pop() diff --git a/link.go b/link.go index a2d8dbf..ebe1230 100644 --- a/link.go +++ b/link.go @@ -56,8 +56,8 @@ func (e *LinkElement) Render(w io.Writer, ctx RenderContext) error { style := ctx.styles.Link if !textRendered { pre = "" - style.Prefix = "" - style.Suffix = "" + style.BlockPrefix = "" + style.BlockSuffix = "" } el := &BaseElement{ diff --git a/paragraph.go b/paragraph.go index 6d8a21a..61b26c5 100644 --- a/paragraph.go +++ b/paragraph.go @@ -22,8 +22,8 @@ func (e *ParagraphElement) Render(w io.Writer, ctx RenderContext) error { } bs.Push(be) - renderText(w, bs.Parent().Style.StylePrimitive, rules.Prefix) - renderText(bs.Current().Block, bs.Current().Style.StylePrimitive, rules.StyledPrefix) + renderText(w, bs.Parent().Style.StylePrimitive, rules.BlockPrefix) + renderText(bs.Current().Block, bs.Current().Style.StylePrimitive, rules.Prefix) return nil } @@ -45,8 +45,8 @@ func (e *ParagraphElement) Finish(w io.Writer, ctx RenderContext) error { _, _ = mw.Write([]byte("\n")) } - renderText(w, bs.Current().Style.StylePrimitive, rules.StyledSuffix) - renderText(w, bs.Parent().Style.StylePrimitive, rules.Suffix) + renderText(w, bs.Current().Style.StylePrimitive, rules.Suffix) + renderText(w, bs.Parent().Style.StylePrimitive, rules.BlockSuffix) bs.Current().Block.Reset() bs.Pop() diff --git a/statik/statik.go b/statik/statik.go index 824873a..1cae186 100644 --- a/statik/statik.go +++ b/statik/statik.go @@ -7,6 +7,6 @@ import ( ) func init() { - data := "PK\x03\x04\x14\x00\x08\x00\x08\x00 \x12\x8dO\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00 \x00dark.jsonUT\x05\x00\x01r\xf4\xf2]\x9cTK\x8e\xdb0\x0c\xdd\xe7\x14\x82\xb2m\x073\xb6\x13\xb4Yt\xdf;\x040\x14\x8bv\x84\xe8\x93\xeaSL\x11\x18\xe8\xaa\x17\xe8\xa2\x9b\x02\xd3\xf6\x10=PO0G(\x9c\x8fE\xdb\x9a\xa4\xa8v\"\x1f\xa5G\xf2\x91\x87\x19!\x94\x9b*(\xd0\x9e\xaeHw'\x84\n\xcdO\xf7\xe2\xd5\xc9\xb0\xb7P\x8bG\xba\"t\xad\xd7\x9a\x9e\xad.\xd4 ke\xa4\xb1\x9d1[dtFH\xdb\xd9\xe9\x16\x18\x17\xba\x89\x7f\xe0\xe0Ih\xfe\xf6b\xda\x18\xc9\xe9\x8ax\x1b \xbe\xf5\x90~\x061\xf3\x9f$\xf02\xd2&#O\x0c\xeb=\x1bV\xed\x1ak\x82\xe6e\xcfc\x99O\xb3\xca\xde\\\xe5\x96En\xb8j/2\x9b\xcf \xaaR\x8e2\x9b\"\x07\xd0\xe2:t\x80]\xdc\xc0\x0e\xc0\xcb[\xe09\x996l1*J\xcd\xa4\x8bU\xf1\xf0x\x94\xd7\xe9&\x85Cb\x93\xf0\x11d\x19%\xd7\x07 \x0f*U\xcc?\x9f\x7f!\xba\xa0\x83\x02\xcb\xbc0:\x05\xbeCP)\xf4\xae\xbcP\xb9\x95\xc0\xa0\xab]d\x0c\n\x9a\x83\x95B\xc3\x196)\xc6}\xfcS(\xd6\xc0\xe8\xd3\xdaX\xc5\xba;}\xdfyW\xe4p\xb8\xeb\x10mK\x9e\x9f~~\x99V7+\xf2\xd1\x8b\xffN&{@SX\x19\x0eW\xba\xfb\x9fS\x92\xe5\xcb)\xe5\xfb|\xf8m\xb9\x91\xa6BET\xcc6B\xa3\x1d\x83\xb2-b\xa8g\x1b Q:\x9e\xb9A#\xbc\xa8v\xc0\x8f\xaa\xf8\xfe\xad'\x89\xad_\x91\x00\x9c\xb7b\x07~kMh\xb6H\x04\xd68\x07\xbc4\xc1\x8f\x1b\x0fj\x8f\x80\xc23)\xaa1\xc6yk\xf0fK\xae\x05\x9bj\xffZ\xbf>\x9f\xd4\xfa,\x90\x8c\x8e\xc5+?\x04\xe3!\xa5\xf2w(I\x0e\xb5\xd0\xa2\x9b\x87\xf22h\x13\x87\x07\xab\x92\x0e\x0e\xae\xb2b\xff\xd24\xad\xf5\xf3\xd3\x8f\xdfxYx%cg\x91\xcd\xed\xd9\xf1\x85v\xd6\xce\xfe\x06\x00\x00\xff\xffPK\x07\x08\xdb\x00\x94|\xe2\x01\x00\x00f\x06\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00\xcc\x10\x8dO\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00 \x00light.jsonUT\x05\x00\x01 \xf2\xf2]\x9cT[\xae\xd30\x10\xfd\xef*,\xf7\x17\xaeJ\x92\x16\xe8\x07\xff\xec\xa1R\xe4\xc6\x93\xd4\xaa\x1f\xc5\x0ftQ\x15\x89/\xb6q\x81E\xb0 Vp\x97\x80\xd2\x97\xa7\x8eo\x8bn\xfe\xdc\xd4VDm\xb8k/*\x9bN \xeaR\x89*\x1b#\xaf\xa0\xd5m\xe8\x15v~\x07{\x05^\xdc\x03OI\xd2\x81\x96I\x17[\xe0\xe1\xf1\xe0\xa5\xe3I\n\x87\x9c%\xe1+\xc8:\xfa\xebB\x12\x1eT\xaes\x7f\xbf\xffF\xda@\x07\x05\x96yat\x0e\xfc\x80\xa0R\xe8m}\x96\x92\xce\xf0\xe3\xad\x11\x0e\xccH\n\x9a\x83\x95B\xc3 \x96\xfa\xa1\\\xc47\x85b\x1d$\x8f\xb6\xc6*6\x9c\xe9\xe7!\xbb$\xfb\xfd\xc3\x80\xe8{\xf2\xfc\xf4\xeb\x07\x19\x1b\xac*\x93\x1b\xff_L1\x9bGnc8\xdc\x18\xe5+W\xa2\x98Wc\xc9\xb3\xf2\xfa\xd9z-M\x83\x9a\xa8\x98\xed\x84F?\x14T\xed,R=[K\x88\xd6q\xde\x8a-\xf8\x8d5\xa1\xdb\xa01Z\xe3\x1c\xf0\xda\x04\x9f\x8e\x0e\xd4\x0e\x01\x85gR4)\xc6yk\xf0\x8f(\xbb\xc567\xc0\x95~{\xfar\xbf,\\\xc8\xa1\xfc\xfaK0\x1er>\xfd\x84|\xca\xa1\x15Z\x0c\x8e\xae\xcf\xab2Jx\xb0*\x9b\xe0\xe0\x1a+v/\xed\xc3J??\xfd\xfc\x83w\xdb+\x19g\x83bn\xc7\x0e7\xf4\x93~\xf2/\x00\x00\xff\xffPK\x07\x08\x82\x830\x0e\xc7\x01\x00\x00\x15\x06\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00\xce\x10\x8dO\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00 \x00notty.jsonUT\x05\x00\x01$\xf2\xf2]\x84\x93_N\x83@\x10\xc6\xdf9\xc5f}k\xb4\x89Z}\xe8\x83\xef\xde\x81\x84R\x18`\xc3\xfe\xc1e15\x0d\xc4'\xafQ\xf5\x10\x1e\xc8\x13\xf4\x08f\xa1v\x07\xd9Z\xdef\xe6\xf7}Cff\xb7\x01!4UI#@\x1a\xba$6&\x842\x99\x0e\xf1\xe2rHT\x1a2\xb6\xa1KBC\x19Jz\xc8\xd6M\x86\xb3\x01!\xad\xad\xd0\x02\xe2\x94\xc9\xdc\xf9a\x10a\xd7~\x0250/\x1c\xd2\xc8u\xbf H~\xe3\xe4\xf8\xffN\x8bG\xea[\xd4|J\x8e\xd0\xc5\xff\xe8\x88\xbd;\xc3\x8e\xe0\xfbs0\xa6\x0dl\xfa\x15\x0d\x11g5Z\x18\x87g\xe0\x91[\xdbQ\xc4\x0c\x08\xdf\x98\xbe_?\x915\xc8F\x80\x8e\x0dS\xd2\x07\xcf\x11\xca\x99,\xa3\xbf\xbf\"K\x171\x11\xe7p$\x06\xabLi\x11\xdb\x98>\xda\xea\x92l\xb7sK\xb4-\xd9\xef>\xde\x90}\xafvf\x89J\xc1\xf7G\xab\xe9 \xae\x9c\x89UEk\xae\x92\xd2iE\xacs&G\xb31\xf1\x9a\xa3^\xb5\xd1\xac\x04Sh\xd5\xe4\x85\xafi\xd7M\xbbv\x1d\x9a\xa2\xa8\xbc\xba\xd9T6s\xaa\xdah\x85\xdf\n\xd2\xf9\x84HYh\xdf\x84Cyu\xf8\xf0[\xeb\xa7\x11=5\xcax\xe7\xf9\x80V\x90B\xc6$\xb3\xb7\x10\xfd\x1e\xd9\xa4`@\x0bo!\x85:\xd1\xac:uI\xa1\xdc\xef\xde\xbf\xf0\x130\x82\xbbU\xa1\\]\xc5\xbdC\x1b\xb4\xc1O\x00\x00\x00\xff\xffPK\x07\x08OGZ\xa4j\x01\x00\x00\xa6\x04\x00\x00PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00 \x12\x8dO\xdb\x00\x94|\xe2\x01\x00\x00f\x06\x00\x00 \x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00dark.jsonUT\x05\x00\x01r\xf4\xf2]PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00\xcc\x10\x8dO\x82\x830\x0e\xc7\x01\x00\x00\x15\x06\x00\x00\n\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\"\x02\x00\x00light.jsonUT\x05\x00\x01 \xf2\xf2]PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00\xce\x10\x8dOOGZ\xa4j\x01\x00\x00\xa6\x04\x00\x00\n\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81*\x04\x00\x00notty.jsonUT\x05\x00\x01$\xf2\xf2]PK\x05\x06\x00\x00\x00\x00\x03\x00\x03\x00\xc2\x00\x00\x00\xd5\x05\x00\x00\x00\x00" + data := "PK\x03\x04\x14\x00\x08\x00\x08\x00\xc8\xb0\x8dO\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00 \x00dark.jsonUT\x05\x00\x01Y\x0b\xf4]\x94TK\x8e\xd3@\x10\xdd\xe7\x14\xad\xce\x16F3v\x12A\x16\xec\xb9C$\xab\xe3.;-\xf7'\xf4\x07\x8d\x14Yb\xc5\x05X\xb0A\x1a\xe0\x10\x1c\x88\x13\xcc\x11\x90\x93\x89\xbb\xec\xb6\x03\xf4\xae\xab^}_U\x9d\x16\x84Pn\xca\xa0@{\xba%\xdd\x9f\x10*4\xbf\xfcW\xaf.\x82\xbd4eS\x1c-T\xe2\x91n \xdd\xe9\x9d\xa6\x03\x9d\x0b\xd5\x84\xae4\xd2\xd8N\x98\xad3\xba \xa4\xed\xe4\xf4\x00\x8c\x0b]\xc7x\xa9\x8b\xc4A\xfe\xb6\x8fg$\xa7[\xe2m\x80\xe8\xf1\xe1\x96\xb3\xe8.V@\xae\xa2\x08\xecE{V6\xb55A\xf3\xa2\x8f\xbf\xc9\xd3\x9a\xb277s\xca\xc69\xe1\xfe\xa5\x19-\x97\x04\xb5(\x8f\xc6\x182\xc0\xacf0\x03\xd0z\x0e4@mfQK\x92r\xb1\x1e\xd5]1\xe9b\xe1\x1e\x1e\xcf\xb3t\xf9I\xe1\xd0dI\xf8\x08\xb2\x88\xf3\xd5\x1b \x0fj\xbe_\xbf?\xfdD\xd9\x82\x0e\n,\xf3\xc2\xe8y\x93;d \x85n\x8akZ\x7f+f@bg\x19\x8d\x82\xe6`\xa5\xd0\xf0\x02K\x1as\x1fc\n\xc5j\x18\x05\xad\x8cU\xac\xfb\xd3\xf7\x9dvKN\xa7\xbb\x0e\xd1\xb6\xe4\xf9\xe9\xc7\xe7\xb4\xd3\xd9*\x1fy\xfc\xf7d\xb2\x07\xb4r\xa5\xe10E\xf1\xff\xaeA\x96o\xd2$\xef\xf3a\xa0\xe2\xccE\x0c\xa7\x98\xad\x85F\xe7\x04\xd5\xb7\x8a\xa6\x9e\xed%\xc4\xc1\xf1\xcc\x0dZ\xefE\xd9\x00?O\xc3\xb7\xaf}\x92X\xfa\x05Q\xee\xbc\x15\x0d\xf8\x835\xa1> \xda\xadq\x0exa\x82\x1fS\x0d\xea\x88\x80\xc23)\xca1\xc6yk\x06\x87kj\xef\xed\x14\xe1;\xfd\xfa\xe5M]\xc7\x15\x1a\x9c\xcb \x7f\x08\xc6\xc3\xfct\xbfC\xa5r\xa8\x84\x16\xdd6\x14\xd7eK\x14\x1e\xac\x9aTpp\xa5\x15\xc7\xdb\xbb\xb4\xd3\xcfO\xdf\x7f\xe1{\xe1\x95\x8c,#\x99;\xb2\xb3\x9fv\xd1.\xfe\x04\x00\x00\xff\xffPK\x07\x08K\xfa\xdc\xc4\xde\x01\x00\x00]\x06\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00\xcc\xb0\x8dO\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00 \x00light.jsonUT\x05\x00\x01a\x0b\xf4]\x94T[\xae\xd30\x10\xfd\xef*,\xf7\x17\xaeJ\x92\x16\xe8\x07\xff\xec\xa1R\xe4\xc6\x93tT?\x8a\x1f\xe8JU$\xbe\xd8\xc6\x05\x16\xc1\x82X\xc1]\x02J_v\x9c\x87 \x7f\x9e93s&\xe7\xd8\xe7\x05!\x94\xeb\xcaKP\x8enIw&\x84\xa2\xe2\xd7s\xf1\xe6\x1a\xd8\x0b]\x1d\xcb\x93\x81\x1a\x9f\xe9\x96\xd0\x9d\xda)\xda\xcbY_\x8f\xe4*-\xb4\xe9\x82Y^\xd0\x05!m\x17\xa7\x07`\x1cU\x13\xe6\x0d[\x0c\x1b\xbc\x7f\xcc\xd3\x82\xd3-q\xc6C\xe8\xf8n\xaeYh\x176 \xf7P\x00>B{V\x1d\x1b\xa3\xbd\xe2\xe5c\xfe&\x1fR\xca>\xccr\xcaRN\xf1\xff\x1b2Z.I\xf4\x8b\xf2P\x1cCz\x98b\x02\xd3\x03\xad\xa7@=\xd4f\x12\xb5$\xc9\x925\x136l\xe9\xe0\xf9b\x9c\xebI\xa0\x8dl$\xe0+\x882\x98\xe9Q\x84\x0e\xe4\xf4\xcf\xf9\xf3\xedWD\x0d\x94\x97`\x98C\xad\xa6K\x9e\xa2\x02\x81\xeaX\xdei\xa5\x92}\x9cS\xac\xab\x0cE^q0\x02\x15\xdc`\xa9\xfc\xf9&\xccD\xc9\x1aH\x86\xd6\xdaH\xd6\x9d\xe9\xe7.\xbb%\xe7\xf3S\x87h[\xf2\xfa\xf2\xf3;\x19\xfa\xa9\xc8\x93\x8e\xffN&[\xadCm\xa59\x8c\xe9\xf9\xbf\x9e\xcf\xd6\xc5\x90\xe4*\xef\x0f*/Z\x84q\x92\x99\x06U\xf4vD\xfb\xadB\xa9c{\x01\xc18\xd6\x19<\x82;\x18\xed\x9bC$\x9c\xd1\xd6\x02/\xb5w\xa9X O\x11\x10\x1d\x13X\xa5\x18\xeb\x8c\xee\xbd3c\xd7\xd4\x8cI\xb6Soo\xdf\xd8[\x14/r\xb5\xe2\x17\xaf\x1dL\xfb\xf3S\xe4O\x0e5*\xec\xfc\\\xde\xaf\xcb \xe1\xc0\xc8\xd1\x04\x07[\x19<\xcd\xdf\x86\x9dz}\xf9\xf1;\xbe\xdeN\x8a\xa0S\x14\xb3'v\xe9\xd3.\xda\xc5\xdf\x00\x00\x00\xff\xffPK\x07\x08\xff\xf2\x1f\xfb\xc4\x01\x00\x00\x0c\x06\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00\xd0\xb0\x8dO\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00 \x00notty.jsonUT\x05\x00\x01i\x0b\xf4]|\x93On\xab0\x10\xc6\xf7\x9c\xc2\xf2\xdbE\xefEzm\xdaE\x16\xdd\xf7\x0eH\xc4\x81\x01,\xfc\x87\x1aSE\x8a@]\xf5\x1ai{\x88\x1e\xa8'\xc8\x11*C\x1b\x0fI\x0c\xbb\xe1\xfb\xbe\x9fG\x9e\xf1>\"\x84f:m%(K\xd7\xc4\xd5\x84P\xae\xb2\xb1^\xfd\x1d\x7fl\x85N\xab\xa46\x90\xf3\x1d]\x13\x1a\xabX\xd1\x89\xd6\xb49\xd6\"B:\xa7\xd3\x12X\xc6U\xe1\xd9\x97vd\xfe?\xe7\xf3G\xfaF\xfe\x10\x94\xbe9O\xe3\x86\xafd'\xe1[\x1f\xc6\x96\x89g\x15\xf0LLw!\xd3\xc4u\x1fta\x9b\x85\xdd0\x96\xb1\x12\xbcAC\x12\xf0\x0c\"\xf1\xa3:\x85\xb8\x05\x19\xbe\x89\xaf\x97\x0ft\x00\xa8V\x82a\x96k\x15\x8e,Q@pU%\xe7m\xa9\xcaW\\\xb2\x02N\x8e\x11\x98k#\x99\xab\xe9\xa3S\xd7d\xbf_:G\xd7\x91\xe3\xe1\xfd\x15\xe1\x87\xb4\x87\xa5:\x83p_\x9b\xd0\nn<\xd0\x11\x92A\xf7\x1c\xc9L\xc1\xd5\xe4\xce,\xdb\ntnc\x0d\xaf\xc0\x96F\xb7E\x19n\xa0\xefC\x1d\xf4=\xbacY\xcf0\x16!\xc4\xc2\x13\x1ak\xf4\xe5\x1bB\x8c0\x04QJsm\"\xb1\xfa\xf7\xf3\xe1\x978r\x9eZmg\xee\xff\x01\x0d.\x83\x9c+\xee\xf6(\xf9]\xd3\x0b\xc1\x82\x91W\x85\x0c\x9a\xd4\xf0z~\x0bcu<\xbc}\xe27d\xa5\xf0\xa3E\xff\x9a\x9a\x0d\x9c.\xea\xa2\xef\x00\x00\x00\xff\xffPK\x07\x08\xabfs3j\x01\x00\x00\xe2\x04\x00\x00PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00\xc8\xb0\x8dOK\xfa\xdc\xc4\xde\x01\x00\x00]\x06\x00\x00 \x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00dark.jsonUT\x05\x00\x01Y\x0b\xf4]PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00\xcc\xb0\x8dO\xff\xf2\x1f\xfb\xc4\x01\x00\x00\x0c\x06\x00\x00\n\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x1e\x02\x00\x00light.jsonUT\x05\x00\x01a\x0b\xf4]PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00\xd0\xb0\x8dO\xabfs3j\x01\x00\x00\xe2\x04\x00\x00\n\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81#\x04\x00\x00notty.jsonUT\x05\x00\x01i\x0b\xf4]PK\x05\x06\x00\x00\x00\x00\x03\x00\x03\x00\xc2\x00\x00\x00\xce\x05\x00\x00\x00\x00" fs.Register(data) } diff --git a/style.go b/style.go index 15e834e..42c5a7f 100644 --- a/style.go +++ b/style.go @@ -12,10 +12,10 @@ import ( ) type StylePrimitive struct { + BlockPrefix string `json:"block_prefix"` + BlockSuffix string `json:"block_suffix"` Prefix string `json:"prefix"` Suffix string `json:"suffix"` - StyledPrefix string `json:"styled_prefix"` - StyledSuffix string `json:"styled_suffix"` Color *string `json:"color"` BackgroundColor *string `json:"background_color"` Underline *bool `json:"underline"` @@ -143,6 +143,8 @@ func cascadeStyle(parent StyleBlock, child StyleBlock, onlyColors bool) StyleBlo s.Overlined = parent.Overlined s.Inverse = parent.Inverse s.Blink = parent.Blink + s.BlockPrefix = parent.BlockPrefix + s.BlockSuffix = parent.BlockSuffix s.Prefix = parent.Prefix s.Suffix = parent.Suffix s.Format = parent.Format @@ -187,6 +189,12 @@ func cascadeStyle(parent StyleBlock, child StyleBlock, onlyColors bool) StyleBlo if child.Blink != nil { s.Blink = child.Blink } + if child.BlockPrefix != "" { + s.BlockPrefix = child.BlockPrefix + } + if child.BlockSuffix != "" { + s.BlockSuffix = child.BlockSuffix + } if child.Prefix != "" { s.Prefix = child.Prefix } diff --git a/styles/README.md b/styles/README.md index af1e3bd..c379f98 100644 --- a/styles/README.md +++ b/styles/README.md @@ -5,16 +5,16 @@ Block elements contain other elements and are rendered around them. All block elements support the following style settings: -| Attribute | Value | Description | -| ---------------- | ------ | -------------------------------------------------- | -| prefix | string | Printed before the block's first element | -| suffix | string | Printed after the block's last element | -| styled_prefix | string | Printed before the block's first element | -| styled_suffix | string | Printed after the block's last element | -| indent | number | Specifies the indentation of the block | -| margin | number | Specifies the margin around the block | -| color | color | Defines the default text color for the block | -| background_color | color | Defines the default background color for the block | +| Attribute | Value | Description | +| ---------------- | ------ | ------------------------------------------------------------ | +| block_prefix | string | Printed before the block's first element (in parent's style) | +| block_suffix | string | Printed after the block's last element (in parent's style) | +| prefix | string | Printed before the block's first element | +| suffix | string | Printed after the block's last element | +| indent | number | Specifies the indentation of the block | +| margin | number | Specifies the margin around the block | +| color | color | Defines the default text color for the block | +| background_color | color | Defines the default background color for the block | Elements inside a block inherit the block's following style settings: @@ -44,8 +44,8 @@ Style: "document": { "indent": 2, "background_color": "234", - "prefix": "\n", - "suffix": "\n" + "block_prefix": "\n", + "block_suffix": "\n" } ``` @@ -99,18 +99,18 @@ Style: "background_color": "57" }, "h1": { - "styled_prefix": "=> ", - "styled_suffix": " <=", + "prefix": "=> ", + "suffix": " <=", "margin": 2, "bold": true, "background_color": "69" }, "h2": { - "styled_prefix": "## ", + "prefix": "## ", "margin": 4 }, "h3": { - "styled_prefix": "### ", + "prefix": "### ", "margin": 6 } ``` @@ -223,10 +223,10 @@ All inline elements support the following style settings: | Attribute | Value | Description | | ---------------- | ------ | ----------------------------------------------------- | +| block_prefix | string | Printed before the element (in parent's style) | +| block_suffix | string | Printed after the element (in parent's style) | | prefix | string | Printed before the element | | suffix | string | Printed after the element | -| styled_prefix | string | Printed before the element | -| styled_suffix | string | Printed after the element | | color | color | Defines the default text color for the document | | background_color | color | Defines the default background color for the document | | bold | bool | Increases text intensity | @@ -275,7 +275,7 @@ Style: ``` "item": { - "prefix": "• " + "block_prefix": "• " } ``` @@ -302,7 +302,7 @@ Style: ``` "enumeration": { - "prefix": ". " + "block_prefix": ". " } ``` @@ -363,8 +363,8 @@ Style: "link": { "color": "123", "underline": true, - "prefix": "(", - "suffix": ")" + "block_prefix": "(", + "block_suffix": ")" } ``` @@ -408,8 +408,8 @@ Style: ``` "image": { "color": "123", - "prefix": "[Image: ", - "suffix": "]" + "block_prefix": "[Image: ", + "block_suffix": "]" } ``` @@ -523,7 +523,7 @@ Style: ``` "hr": { - "prefix": "---" + "block_prefix": "---" } ``` diff --git a/styles/dark.json b/styles/dark.json index 39bca31..56ad03e 100644 --- a/styles/dark.json +++ b/styles/dark.json @@ -1,38 +1,38 @@ { "document": { "indent": 4, - "prefix": "\n\n", - "suffix": "\n\n", + "block_prefix": "\n\n", + "block_suffix": "\n\n", "color": "252" }, "heading": { - "suffix": "\n", + "block_suffix": "\n", "color": "39", "bold": true }, "h1": { - "suffix": "\n\n", - "styled_prefix": " ", - "styled_suffix": " ", + "block_suffix": "\n\n", + "prefix": " ", + "suffix": " ", "background_color": "63", "color": "228", "bold": true }, "h2": { - "prefix": "\n", - "styled_prefix": "## " + "block_prefix": "\n", + "prefix": "## " }, "h3": { - "styled_prefix": "### " + "prefix": "### " }, "h4": { - "styled_prefix": "#### " + "prefix": "#### " }, "h5": { - "styled_prefix": "##### " + "prefix": "##### " }, "h6": { - "styled_prefix": "###### ", + "prefix": "###### ", "color": "35", "bold": false }, @@ -41,10 +41,10 @@ "level_indent": 4 }, "item": { - "prefix": "• " + "block_prefix": "• " }, "enumeration": { - "prefix": ". " + "block_prefix": ". " }, "link_text": { "color": "35", @@ -63,8 +63,8 @@ "color": "212" }, "code": { - "styled_prefix": " ", - "styled_suffix": " ", + "prefix": " ", + "suffix": " ", "background_color": "236", "color": "203" }, @@ -91,12 +91,12 @@ "color": "240" }, "block_quote": { - "prefix": "> " + "block_prefix": "> " }, "definition_list": {}, "definition_term": {}, "definition_description": { - "prefix": "\n🠶 " + "block_prefix": "\n🠶 " }, "html_block": {}, "html_span": {} diff --git a/styles/examples/document.style b/styles/examples/document.style index 6703ccc..813a8c5 100644 --- a/styles/examples/document.style +++ b/styles/examples/document.style @@ -2,7 +2,7 @@ "document": { "indent": 2, "background_color": "234", - "prefix": "\n", - "suffix": "\n" + "block_prefix": "\n", + "block_suffix": "\n" } } diff --git a/styles/examples/enumeration.style b/styles/examples/enumeration.style index 0441fc1..3dbf2bc 100644 --- a/styles/examples/enumeration.style +++ b/styles/examples/enumeration.style @@ -4,6 +4,6 @@ "background_color": "52" }, "enumeration": { - "prefix": ". " + "block_prefix": ". " } } diff --git a/styles/examples/heading.style b/styles/examples/heading.style index 4e21e3a..8731f4c 100644 --- a/styles/examples/heading.style +++ b/styles/examples/heading.style @@ -4,18 +4,18 @@ "background_color": "57" }, "h1": { - "styled_prefix": "=> ", - "styled_suffix": " <=", + "prefix": "=> ", + "suffix": " <=", "margin": 2, "bold": true, "background_color": "69" }, "h2": { - "styled_prefix": "## ", + "prefix": "## ", "margin": 4 }, "h3": { - "styled_prefix": "### ", + "prefix": "### ", "margin": 6 } } diff --git a/styles/examples/image.style b/styles/examples/image.style index e77d016..3445a68 100644 --- a/styles/examples/image.style +++ b/styles/examples/image.style @@ -1,8 +1,8 @@ { "image": { "color": "123", - "prefix": "[Image: ", - "suffix": "]" + "block_prefix": "[Image: ", + "block_suffix": "]" }, "image_text": { "color": "8" diff --git a/styles/examples/link.style b/styles/examples/link.style index 9941dbf..69ac05b 100644 --- a/styles/examples/link.style +++ b/styles/examples/link.style @@ -2,8 +2,8 @@ "link": { "color": "123", "underline": true, - "prefix": "(", - "suffix": ")" + "block_prefix": "(", + "block_suffix": ")" }, "link_text": { "color": "123", diff --git a/styles/examples/list.style b/styles/examples/list.style index ce197c7..0a6c648 100644 --- a/styles/examples/list.style +++ b/styles/examples/list.style @@ -5,6 +5,6 @@ "level_indent": 4 }, "item": { - "prefix": "• " + "block_prefix": "• " } } diff --git a/styles/light.json b/styles/light.json index 0278a3b..7b87657 100644 --- a/styles/light.json +++ b/styles/light.json @@ -1,38 +1,38 @@ { "document": { "indent": 4, - "prefix": "\n\n", - "suffix": "\n\n", + "block_prefix": "\n\n", + "block_suffix": "\n\n", "color": "234" }, "heading": { - "suffix": "\n", + "block_suffix": "\n", "color": "27", "bold": true }, "h1": { - "suffix": "\n\n", - "styled_prefix": " ", - "styled_suffix": " ", + "block_suffix": "\n\n", + "prefix": " ", + "suffix": " ", "background_color": "63", "color": "228", "bold": true }, "h2": { - "prefix": "\n", - "styled_prefix": "## " + "block_prefix": "\n", + "prefix": "## " }, "h3": { - "styled_prefix": "### " + "prefix": "### " }, "h4": { - "styled_prefix": "#### " + "prefix": "#### " }, "h5": { - "styled_prefix": "##### " + "prefix": "##### " }, "h6": { - "styled_prefix": "###### ", + "prefix": "###### ", "bold": false }, "text": {}, @@ -40,10 +40,10 @@ "level_indent": 4 }, "item": { - "prefix": "• " + "block_prefix": "• " }, "enumeration": { - "prefix": ". " + "block_prefix": ". " }, "link_text": { "color": "29", @@ -62,8 +62,8 @@ "color": "205" }, "code": { - "styled_prefix": " ", - "styled_suffix": " ", + "prefix": " ", + "suffix": " ", "background_color": "254", "color": "203" }, @@ -86,12 +86,12 @@ "color": "240" }, "block_quote": { - "prefix": "> " + "block_prefix": "> " }, "definition_list": {}, "definition_term": {}, "definition_description": { - "prefix": "\n🠶 " + "block_prefix": "\n🠶 " }, "html_block": {}, "html_span": {} diff --git a/styles/notty.json b/styles/notty.json index d0c5416..290129f 100644 --- a/styles/notty.json +++ b/styles/notty.json @@ -1,41 +1,41 @@ { "document": { "indent": 4, - "prefix": "\n\n", - "suffix": "\n\n" + "block_prefix": "\n\n", + "block_suffix": "\n\n" }, "heading": { - "suffix": "\n" + "block_suffix": "\n" }, "h1": { - "suffix": "\n\n", - "styled_prefix": "# " + "block_suffix": "\n\n", + "prefix": "# " }, "h2": { - "prefix": "\n", - "styled_prefix": "## " + "block_prefix": "\n", + "prefix": "## " }, "h3": { - "styled_prefix": "### " + "prefix": "### " }, "h4": { - "styled_prefix": "#### " + "prefix": "#### " }, "h5": { - "styled_prefix": "##### " + "prefix": "##### " }, "h6": { - "styled_prefix": "###### " + "prefix": "###### " }, "text": {}, "list": { "level_indent": 4 }, "item": { - "prefix": "• " + "block_prefix": "• " }, "enumeration": { - "prefix": ". " + "block_prefix": ". " }, "link_text": {}, "link": {}, @@ -44,35 +44,35 @@ }, "image": {}, "code": { - "prefix": "`", - "suffix": "`" + "block_prefix": "`", + "block_suffix": "`" }, "code_block": { "margin": 4 }, "table": {}, "strikethrough": { - "prefix": "~~", - "suffix": "~~" + "block_prefix": "~~", + "block_suffix": "~~" }, "emph": { - "prefix": "*", - "suffix": "*" + "block_prefix": "*", + "block_suffix": "*" }, "strong": { - "prefix": "**", - "suffix": "**" + "block_prefix": "**", + "block_suffix": "**" }, "hr": { "format": "\n--------\n" }, "block_quote": { - "prefix": "> " + "block_prefix": "> " }, "definition_list": {}, "definition_term": {}, "definition_description": { - "prefix": "\n🠶 " + "block_prefix": "\n🠶 " }, "html_block": {}, "html_span": {} diff --git a/table.go b/table.go index 48cb6c7..5f86742 100644 --- a/table.go +++ b/table.go @@ -47,7 +47,7 @@ func (e *TableElement) Render(w io.Writer, ctx RenderContext) error { }, } - renderText(ctx.table.indentWriter, bs.Current().Style.StylePrimitive, rules.Prefix) + renderText(ctx.table.indentWriter, bs.Current().Style.StylePrimitive, rules.BlockPrefix) ctx.table.writer = tablewriter.NewWriter(ctx.table.indentWriter) return nil } @@ -57,7 +57,7 @@ func (e *TableElement) Finish(w io.Writer, ctx RenderContext) error { ctx.table.writer = nil rules := ctx.styles.Table - renderText(ctx.table.indentWriter, ctx.blockStack.Current().Style.StylePrimitive, rules.Suffix) + renderText(ctx.table.indentWriter, ctx.blockStack.Current().Style.StylePrimitive, rules.BlockSuffix) return nil }