diff --git a/App/Localization/ar.lproj/Credits.rtf b/App/Localization/ar.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/ar.lproj/Credits.rtf +++ b/App/Localization/ar.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/de.lproj/Credits.rtf b/App/Localization/de.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/de.lproj/Credits.rtf +++ b/App/Localization/de.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/en.lproj/Credits.rtf b/App/Localization/en.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/en.lproj/Credits.rtf +++ b/App/Localization/en.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/es.lproj/Credits.rtf b/App/Localization/es.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/es.lproj/Credits.rtf +++ b/App/Localization/es.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/fr.lproj/Credits.rtf b/App/Localization/fr.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/fr.lproj/Credits.rtf +++ b/App/Localization/fr.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/is.lproj/Credits.rtf b/App/Localization/is.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/is.lproj/Credits.rtf +++ b/App/Localization/is.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/it-IT.lproj/Credits.rtf b/App/Localization/it-IT.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/it-IT.lproj/Credits.rtf +++ b/App/Localization/it-IT.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/ja.lproj/Credits.rtf b/App/Localization/ja.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/ja.lproj/Credits.rtf +++ b/App/Localization/ja.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/ko-KR.lproj/Credits.rtf b/App/Localization/ko-KR.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/ko-KR.lproj/Credits.rtf +++ b/App/Localization/ko-KR.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/pt-BR.lproj/Credits.rtf b/App/Localization/pt-BR.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/pt-BR.lproj/Credits.rtf +++ b/App/Localization/pt-BR.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/sk.lproj/Credits.rtf b/App/Localization/sk.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/sk.lproj/Credits.rtf +++ b/App/Localization/sk.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/sv.lproj/Credits.rtf b/App/Localization/sv.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/sv.lproj/Credits.rtf +++ b/App/Localization/sv.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/zh-Hans.lproj/Credits.rtf b/App/Localization/zh-Hans.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/zh-Hans.lproj/Credits.rtf +++ b/App/Localization/zh-Hans.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/App/Localization/zh-Hant.lproj/Credits.rtf b/App/Localization/zh-Hant.lproj/Credits.rtf index 9ace71f..0e2f464 100644 --- a/App/Localization/zh-Hant.lproj/Credits.rtf +++ b/App/Localization/zh-Hant.lproj/Credits.rtf @@ -93,6 +93,8 @@ Open source Markdown editor for OS X. {\field{\*\fldinst{HYPERLINK "https://github.com/tinglou"}}{\fldrslt \cf0 Ting Lou}}\ \pard\pardeftab720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://www.loopingz.com/"}}{\fldrslt \cf0 Remi Cattiau}}\ +\pard\pardeftab720\partightenfactor0 +{\field{\*\fldinst{HYPERLINK "https://github.com/levous"}}{\fldrslt \cf0 LeVous (Rusty Zarse)}}\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 @@ -160,28 +162,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 \cf0 Hoedown}}\ -Copyright \'a9 2008, Natacha Port\'e9\ -Copyright \'a9 2011, Vicent Mart\'ed\ -Copyright \'a9 2013, Devin Torres and the Hoedown authors\ -\ -Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\ -\ -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\ -\ -{\field{\*\fldinst{HYPERLINK "https://github.com/hoedown/hoedown"}}{\fldrslt -\b\fs28 Hoextdown}} -\b\fs28 \ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 - -\b0\fs24 \cf0 Copyright \'a9 2014 kjdev\ +{\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark"}}{\fldrslt +\b\fs28 \cf0 cmark-gfm}}\ +Copyright \'a9 2014, John MacFarlane\ +All rights reserved.\ \ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ \ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ \ -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ +cmark-gfm includes code from other projects under their own notices: see {\field{\*\fldinst{HYPERLINK "https://github.com/swiftlang/swift-cmark/blob/main/COPYING"}}{\fldrslt https://github.com/swiftlang/swift-cmark/blob/main/COPYING}}.\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://pyyaml.org/wiki/LibYAML"}}{\fldrslt @@ -249,6 +241,8 @@ Copyright 2011 Ali Rantakari -- <{\field{\*\fldinst{HYPERLINK "http://hasseg.org \ PEG-Markdown-Highlight is licensed under the same terms as peg-markdown (see below for more information).\ \ +MacDown's editor highlighter and theme parser are Swift ports of PEG Markdown Highlight's code, so that editor themes keep working; the library itself is no longer used.\ +\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/jgm/peg-markdown"}}{\fldrslt \b\fs28 \cf0 peg-markdown}}\ diff --git a/CLAUDE.md b/CLAUDE.md index 982863a..35fe6ce 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -28,7 +28,7 @@ There is no linter configured. ## Build structure -- `Package.swift` (SwiftPM) holds everything except the app's `@main`: the C targets `CHoedown` and `CPegMarkdown`, `MacDownShared`, `MacDownKit`, the `macdown-cmd` executable, and the tests. Almost all code lives in `MacDownKit`. `App/MacDownApp.swift` only wires `MacDownScene` and `MacDownAppDelegate`. +- `Package.swift` (SwiftPM) holds everything except the app's `@main`: `MacDownShared`, `MacDownKit`, the `macdown-cmd` executable, and the tests. The Markdown parser is swift-cmark (cmark-gfm), pinned exactly. Almost all code lives in `MacDownKit`. `App/MacDownApp.swift` only wires `MacDownScene` and `MacDownAppDelegate`. - `project.yml` (XcodeGen) defines the `MacDown` app target, which depends on the local package, and embeds the `macdown` tool in `Contents/SharedSupport/bin`. Edit `project.yml`, not the generated `.xcodeproj`. - Resources load through `MPPaths.resourceBundle` (`Bundle.module`). New resource directories must be added to the `resources:` list in `Package.swift`. - Strict concurrency is on (`swiftLanguageModes: [.v6]`, `SWIFT_STRICT_CONCURRENCY: complete`). UI types are `@MainActor`, and parsing runs off the main actor. @@ -36,12 +36,12 @@ There is no linter configured. ## Render pipeline 1. `DocumentController` (one per window, the central `@MainActor` coordinator that owns the editor, preview, renderer and the formatting/export actions) observes editor text and preference changes. -2. `Preferences.renderSettings` turns preferences into `RenderSettings` = `ParseSettings` (Markdown options, stored as hoedown's flags, and the hidden `markdownEngine`) + `PageSettings` (styles, Prism, MathJax, Mermaid, Graphviz, template). -3. `Renderer.parse` builds a `MarkdownDocumentModel` in a detached task (a generation counter discards superseded parses). The model (`Document/Model`, the only code that calls cmark-gfm) protects math and front matter (`ProtectedSource`), parses once with cmark-gfm (`CMarkTree`), and walks the tree there: `HTMLRenderer` writes the preview body (hoedown's markup, Prism languages, `[TOC]`, front matter table, math for MathJax, `data-source-line` for scroll sync) and `HighlightMapper` the editor's highlight spans and blocks. Only `Sendable` results leave the task. With `markdownEngine = hoedown` (selectable for one release, then removed) `MarkdownParser` renders with the original's patched hoedown instead. +2. `Preferences.renderSettings` turns preferences into `RenderSettings` = `ParseSettings` (the opt-in Markdown options; standard Markdown is always on) + `PageSettings` (styles, Prism, MathJax, Mermaid, Graphviz, template). +3. `Renderer.parse` builds a `MarkdownDocumentModel` in a detached task (a generation counter discards superseded parses). The model (`Document/Model`, the only code that calls cmark-gfm) protects math and front matter (`ProtectedSource`), parses once with cmark-gfm (`CMarkTree`), and walks the tree there: `HTMLRenderer` writes the preview body (hoedown's markup, Prism languages, `[TOC]`, front matter table, math for MathJax, `data-source-line` for scroll sync) and `HighlightMapper` the editor's highlight spans and blocks. Only `Sendable` results leave the task. 4. `PageBuilder` (pure static functions) builds the full HTML page from the parse result using `HTMLTemplate` (a minimal Handlebars subset) and `Asset` (linked or embedded CSS/JS). The same builder makes the preview HTML and the HTML/PDF export, with different embedding options. 5. `PreviewController` loads the page into a `WKWebView`. File URLs are rewritten to `x-macdown-preview://local/` (`PreviewURL` / `LocalFileSchemeHandler`) because WKWebView pages loaded from a string can't read local files. Metrics for scroll sync, word count and background color come back via JS evaluation and script message handlers. When a new page differs from the loaded one only between the `` markers (added by `previewHTML` only, not exports), `load` swaps the body in place and re-runs the page scripts instead of reloading; anything that changes styles, scripts or the base URL reloads the page. -The output keeps hoedown's markup where CommonMark agrees; `HTMLRendererTests` compare it with hoedown byte for byte, and every remaining difference over the test corpus is reviewed in `Tests/MacDownKitTests/Resources/reviewed-html-diffs.json` and summarized in docs/MACDOWN-PORT.md. Don't add C: renderer changes go in `HTMLRenderer`. +The output keeps the markup the original's hoedown wrote where CommonMark agrees (classes, code blocks, footnotes), so its styles and scripts apply; `HTMLRendererTests` compare it byte for byte with hoedown's output, recorded before hoedown was removed (`Tests/MacDownKitTests/Resources/engine-snapshots.json`), and the differences are summarized in docs/MACDOWN-PORT.md. Don't add C: renderer changes go in `HTMLRenderer`. ## Saving @@ -49,7 +49,7 @@ The editor edits a draft (its text); `MarkdownDocument.text` is the persisted st ## Editor -`EditorTextView` (an `NSTextView` subclass) is hosted in SwiftUI through `Representables`. The editing helpers (list/blockquote continuation, auto-pairing, toggling markup, indenting) are in `NSTextView+Autocomplete.swift` and are called from `DocumentController`'s `NSTextViewDelegate` methods. Pasting formatted text (`EditorTextView+Paste.swift`) converts the clipboard's HTML or rich text with `HTMLToMarkdown` (`Document/HTMLToMarkdown`) in `readSelection(from:type:)`, which Paste, Services and drops all go through; see docs/ARCHITECTURE.md, "Pasting". Syntax highlighting is `MarkdownHighlighter`, which styles the visible range from spans keyed by PEG Markdown Highlight's element types, so the original `.style` themes (parsed by `ThemeStyle`) apply. The spans come from the document model's `HighlightMapper` (handed over by `DocumentController` after each parse); with the hoedown engine, from the PEG C parser, whose `pmh_parser.c` is generated code (see docs/ARCHITECTURE.md). Don't hand-edit it. +`EditorTextView` (an `NSTextView` subclass) is hosted in SwiftUI through `Representables`. The editing helpers (list/blockquote continuation, auto-pairing, toggling markup, indenting) are in `NSTextView+Autocomplete.swift` and are called from `DocumentController`'s `NSTextViewDelegate` methods. Pasting formatted text (`EditorTextView+Paste.swift`) converts the clipboard's HTML or rich text with `HTMLToMarkdown` (`Document/HTMLToMarkdown`) in `readSelection(from:type:)`, which Paste, Services and drops all go through; see docs/ARCHITECTURE.md, "Pasting". Syntax highlighting is `MarkdownHighlighter`, which styles the visible range from spans keyed by `HighlightElement` (PEG Markdown Highlight's element types), so the original `.style` themes (parsed by `ThemeStyle`) apply. The spans come from the document model's `HighlightMapper`, handed over by `DocumentController` after each parse. `MarkdownHighlighter` and `ThemeStyle` are Swift ports of PEG Markdown Highlight's code (its license stays in `Licenses/`); the C library itself is gone. ## App ↔ shell utility @@ -68,4 +68,4 @@ Debug builds write a JSON report of each preview render (Prism tokens, TOC links The bundled help (`Resources/help.md`) has a live example of every Markdown feature and setting, and `HelpDocumentTests` renders it, checks the editor highlighting over it, and loads it in the real preview (Prism, Mermaid, Graphviz, images, task lists). When you add or change a feature, update its section in `help.md` and the matching expectations. Live examples that need a setting use text distinct from the "Inline Formatting" table, which shows results as literal HTML. -The tests use Swift Testing (`@Suite`/`@Test`), not XCTest, which runs suites in parallel. Suites that drive a real `DocumentController` with a live WKWebView or change `Preferences.shared` (`DocumentControllerTests`, `ScrollSyncIntegrationTests`) are nested in the serialized `LiveDocumentTests` suite so they don't interfere; put new ones there too. WebKit doesn't run animation frames in the (off-screen) test windows, so the page's scroll and layout reports don't fire; tests call `PreviewController.pageDidScroll(to:)` / `pageLayoutDidChange()` instead. Test fixtures are in `Tests/MacDownKitTests/Resources`. The migration corpus (`Resources/Corpus`) is generated test Markdown; never add real user documents or other docs to it. `HTMLDiffHarnessTests` and `HighlightDiffHarnessTests` compare the engines over it and fail on any difference not reviewed (`Resources/reviewed-html-diffs.json`, `HighlightDiffHarnessTests.reviewed`, `Resources/expected-html-diffs.json`); `MACDOWN_DIFF_REPORT=` writes reports (see docs/ARCHITECTURE.md, "Tests"). Live tests that depend on the engine set `Preferences.shared.markdownEngine` themselves. +The tests use Swift Testing (`@Suite`/`@Test`), not XCTest, which runs suites in parallel. Suites that drive a real `DocumentController` with a live WKWebView or change `Preferences.shared` (`DocumentControllerTests`, `ScrollSyncIntegrationTests`) are nested in the serialized `LiveDocumentTests` suite so they don't interfere; put new ones there too. WebKit doesn't run animation frames in the (off-screen) test windows, so the page's scroll and layout reports don't fire; tests call `PreviewController.pageDidScroll(to:)` / `pageLayoutDidChange()` instead. Test fixtures are in `Tests/MacDownKitTests/Resources`. The migration corpus (`Resources/Corpus`) is generated test Markdown; never add real user documents or other docs to it. `PasteRoundTripTests` converts it back from HTML and fails on any difference not reviewed (`Resources/reviewed-paste-diffs.json`); `MACDOWN_DIFF_REPORT=` writes a report (see docs/ARCHITECTURE.md, "Tests"). diff --git a/Licenses/README.md b/Licenses/README.md new file mode 100644 index 0000000..98d0e14 --- /dev/null +++ b/Licenses/README.md @@ -0,0 +1,17 @@ +# Third-party licenses + +What each license here covers in MacDown: + +| File | Covers | +|---|---| +| `cmark-gfm.txt` | [swift-cmark](https://github.com/swiftlang/swift-cmark) (cmark-gfm and its GFM extensions), the Markdown parser | +| `peg-markdown-highlight.txt` | The Swift ports of PEG Markdown Highlight's editor highlighter (`MarkdownHighlighter.swift`) and theme parser (`ThemeStyleParser.swift`). The C library itself is no longer used; the ports keep the `.style` themes working | +| `libyaml.txt` | libyaml, through [Yams](https://github.com/jpsim/Yams), for front matter | +| `prism.txt` | Prism, syntax highlighting in the preview | +| `mermaid.txt` | Mermaid diagrams | +| `graphviz.txt` | Graphviz (viz.js) diagrams | +| `markdown-mark.txt` | The Markdown mark image in the help | +| `macdown.txt` | The original MacDown, which this app ports | + +hoedown and PEG Markdown Highlight's C parser were removed on 2026-10-22, +when the move to cmark-gfm finished (docs/MACDOWN-PORT.md). diff --git a/Licenses/hoedown.txt b/Licenses/hoedown.txt deleted file mode 100644 index 72ceb93..0000000 --- a/Licenses/hoedown.txt +++ /dev/null @@ -1,15 +0,0 @@ -Copyright (c) 2008, Natacha Porté -Copyright (c) 2011, Vicent Martí -Copyright (c) 2013, Devin Torres and the Hoedown authors - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Licenses/hoextdown.txt b/Licenses/hoextdown.txt deleted file mode 100644 index 190e257..0000000 --- a/Licenses/hoextdown.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014 kjdev - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Licenses/peg-markdown-highlight.txt b/Licenses/peg-markdown-highlight.txt index 077df54..2a31bfd 100644 --- a/Licenses/peg-markdown-highlight.txt +++ b/Licenses/peg-markdown-highlight.txt @@ -1,3 +1,12 @@ +Note for MacDown: the PEG Markdown Highlight library itself is no longer +used or shipped. MacDown's editor highlighter +(Sources/MacDownKit/Editor/MarkdownHighlighter.swift, from +HGMarkdownHighlighter.m and HGMarkdownHighlightingStyle.m) and its theme +parser (Sources/MacDownKit/Editor/ThemeStyleParser.swift, from +pmh_styleparser.c) are Swift ports of its code, kept so that the bundled and +users' `.style` editor themes keep working after the move to cmark-gfm. This +license covers those ports. + PEG Markdown Highlight ====================== diff --git a/Package.swift b/Package.swift index 4bfdfba..456c713 100644 --- a/Package.swift +++ b/Package.swift @@ -21,30 +21,12 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/jpsim/Yams.git", from: "5.1.0"), - // The Markdown parser (docs/intents/swift-markdown-migration.md, - // Decision 10), pinned exactly: the diff harnesses compare its output. + // The Markdown parser (see docs/ARCHITECTURE.md, "Parse with cmark-gfm + // directly"), pinned exactly: the renderer tests and the paste round + // trip compare its output byte for byte. .package(url: "https://github.com/swiftlang/swift-cmark.git", exact: "0.9.0"), ], targets: [ - // Hoedown 3.0.7 plus MacDown's renderer patches (task lists, code block - // information, Prism-compatible code blocks, TOC class). - .target( - name: "CHoedown", - path: "Sources/CHoedown", - exclude: ["LICENSE"], - cSettings: [ - .unsafeFlags(["-Wno-everything"]), - ] - ), - // PEG Markdown Highlight. pmh_parser.c is generated from - // pmh_grammar.leg with greg; see Vendor/README.md. - .target( - name: "CPegMarkdown", - path: "Sources/CPegMarkdown", - cSettings: [ - .unsafeFlags(["-Wno-everything"]), - ] - ), // Constants shared by the app and the `macdown` command line utility. .target( name: "MacDownShared", @@ -53,8 +35,6 @@ let package = Package( .target( name: "MacDownKit", dependencies: [ - "CHoedown", - "CPegMarkdown", "MacDownShared", .product(name: "Yams", package: "Yams"), .product(name: "cmark-gfm", package: "swift-cmark"), diff --git a/Sources/CHoedown/LICENSE b/Sources/CHoedown/LICENSE deleted file mode 100644 index 4e75de4..0000000 --- a/Sources/CHoedown/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -Copyright (c) 2008, Natacha Porté -Copyright (c) 2011, Vicent Martí -Copyright (c) 2014, Xavier Mendez, Devin Torres and the Hoedown authors - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Sources/CHoedown/autolink.c b/Sources/CHoedown/autolink.c deleted file mode 100644 index e7019fd..0000000 --- a/Sources/CHoedown/autolink.c +++ /dev/null @@ -1,281 +0,0 @@ -#include "autolink.h" - -#include -#include -#include -#include - -#ifndef _MSC_VER -#include -#else -#define strncasecmp _strnicmp -#endif - -int -hoedown_autolink_is_safe(const uint8_t *data, size_t size) -{ - static const size_t valid_uris_count = 6; - static const char *valid_uris[] = { - "http://", "https://", "/", "#", "ftp://", "mailto:" - }; - static const size_t valid_uris_size[] = { 7, 8, 1, 1, 6, 7 }; - size_t i; - - for (i = 0; i < valid_uris_count; ++i) { - size_t len = valid_uris_size[i]; - - if (size > len && - strncasecmp((char *)data, valid_uris[i], len) == 0 && - isalnum(data[len])) - return 1; - } - - return 0; -} - -static size_t -autolink_delim(uint8_t *data, size_t link_end, size_t max_rewind, size_t size) -{ - uint8_t cclose, copen = 0; - size_t i; - - for (i = 0; i < link_end; ++i) - if (data[i] == '<') { - link_end = i; - break; - } - - while (link_end > 0) { - if (strchr("?!.,:", data[link_end - 1]) != NULL) - link_end--; - - else if (data[link_end - 1] == ';') { - size_t new_end = link_end - 2; - - while (new_end > 0 && isalpha(data[new_end])) - new_end--; - - if (new_end < link_end - 2 && data[new_end] == '&') - link_end = new_end; - else - link_end--; - } - else break; - } - - if (link_end == 0) - return 0; - - cclose = data[link_end - 1]; - - switch (cclose) { - case '"': copen = '"'; break; - case '\'': copen = '\''; break; - case ')': copen = '('; break; - case ']': copen = '['; break; - case '}': copen = '{'; break; - } - - if (copen != 0) { - size_t closing = 0; - size_t opening = 0; - size_t i = 0; - - /* Try to close the final punctuation sign in this same line; - * if we managed to close it outside of the URL, that means that it's - * not part of the URL. If it closes inside the URL, that means it - * is part of the URL. - * - * Examples: - * - * foo http://www.pokemon.com/Pikachu_(Electric) bar - * => http://www.pokemon.com/Pikachu_(Electric) - * - * foo (http://www.pokemon.com/Pikachu_(Electric)) bar - * => http://www.pokemon.com/Pikachu_(Electric) - * - * foo http://www.pokemon.com/Pikachu_(Electric)) bar - * => http://www.pokemon.com/Pikachu_(Electric)) - * - * (foo http://www.pokemon.com/Pikachu_(Electric)) bar - * => foo http://www.pokemon.com/Pikachu_(Electric) - */ - - while (i < link_end) { - if (data[i] == copen) - opening++; - else if (data[i] == cclose) - closing++; - - i++; - } - - if (closing != opening) - link_end--; - } - - return link_end; -} - -static size_t -check_domain(uint8_t *data, size_t size, int allow_short) -{ - size_t i, np = 0; - - if (!isalnum(data[0])) - return 0; - - for (i = 1; i < size - 1; ++i) { - if (strchr(".:", data[i]) != NULL) np++; - else if (!isalnum(data[i]) && data[i] != '-') break; - } - - if (allow_short) { - /* We don't need a valid domain in the strict sense (with - * least one dot; so just make sure it's composed of valid - * domain characters and return the length of the the valid - * sequence. */ - return i; - } else { - /* a valid domain needs to have at least a dot. - * that's as far as we get */ - return np ? i : 0; - } -} - -size_t -hoedown_autolink__www( - size_t *rewind_p, - hoedown_buffer *link, - uint8_t *data, - size_t max_rewind, - size_t size, - unsigned int flags) -{ - size_t link_end; - - if (max_rewind > 0 && !ispunct(data[-1]) && !isspace(data[-1])) - return 0; - - if (size < 4 || memcmp(data, "www.", strlen("www.")) != 0) - return 0; - - link_end = check_domain(data, size, 0); - - if (link_end == 0) - return 0; - - while (link_end < size && !isspace(data[link_end])) - link_end++; - - link_end = autolink_delim(data, link_end, max_rewind, size); - - if (link_end == 0) - return 0; - - hoedown_buffer_put(link, data, link_end); - *rewind_p = 0; - - return (int)link_end; -} - -size_t -hoedown_autolink__email( - size_t *rewind_p, - hoedown_buffer *link, - uint8_t *data, - size_t max_rewind, - size_t size, - unsigned int flags) -{ - size_t link_end, rewind; - int nb = 0, np = 0; - - for (rewind = 0; rewind < max_rewind; ++rewind) { - uint8_t c = data[-1 - rewind]; - - if (isalnum(c)) - continue; - - if (strchr(".+-_", c) != NULL) - continue; - - break; - } - - if (rewind == 0) - return 0; - - for (link_end = 0; link_end < size; ++link_end) { - uint8_t c = data[link_end]; - - if (isalnum(c)) - continue; - - if (c == '@') - nb++; - else if (c == '.' && link_end < size - 1) - np++; - else if (c != '-' && c != '_') - break; - } - - if (link_end < 2 || nb != 1 || np == 0 || - !isalpha(data[link_end - 1])) - return 0; - - link_end = autolink_delim(data, link_end, max_rewind, size); - - if (link_end == 0) - return 0; - - hoedown_buffer_put(link, data - rewind, link_end + rewind); - *rewind_p = rewind; - - return link_end; -} - -size_t -hoedown_autolink__url( - size_t *rewind_p, - hoedown_buffer *link, - uint8_t *data, - size_t max_rewind, - size_t size, - unsigned int flags) -{ - size_t link_end, rewind = 0, domain_len; - - if (size < 4 || data[1] != '/' || data[2] != '/') - return 0; - - while (rewind < max_rewind && isalpha(data[-1 - rewind])) - rewind++; - - if (!hoedown_autolink_is_safe(data - rewind, size + rewind)) - return 0; - - link_end = strlen("://"); - - domain_len = check_domain( - data + link_end, - size - link_end, - flags & HOEDOWN_AUTOLINK_SHORT_DOMAINS); - - if (domain_len == 0) - return 0; - - link_end += domain_len; - while (link_end < size && !isspace(data[link_end])) - link_end++; - - link_end = autolink_delim(data, link_end, max_rewind, size); - - if (link_end == 0) - return 0; - - hoedown_buffer_put(link, data - rewind, link_end + rewind); - *rewind_p = rewind; - - return link_end; -} diff --git a/Sources/CHoedown/buffer.c b/Sources/CHoedown/buffer.c deleted file mode 100644 index af77b70..0000000 --- a/Sources/CHoedown/buffer.c +++ /dev/null @@ -1,308 +0,0 @@ -#include "buffer.h" - -#include -#include -#include -#include - -void * -hoedown_malloc(size_t size) -{ - void *ret = malloc(size); - - if (!ret) { - fprintf(stderr, "Allocation failed.\n"); - abort(); - } - - return ret; -} - -void * -hoedown_calloc(size_t nmemb, size_t size) -{ - void *ret = calloc(nmemb, size); - - if (!ret) { - fprintf(stderr, "Allocation failed.\n"); - abort(); - } - - return ret; -} - -void * -hoedown_realloc(void *ptr, size_t size) -{ - void *ret = realloc(ptr, size); - - if (!ret) { - fprintf(stderr, "Allocation failed.\n"); - abort(); - } - - return ret; -} - -void -hoedown_buffer_init( - hoedown_buffer *buf, - size_t unit, - hoedown_realloc_callback data_realloc, - hoedown_free_callback data_free, - hoedown_free_callback buffer_free) -{ - assert(buf); - - buf->data = NULL; - buf->size = buf->asize = 0; - buf->unit = unit; - buf->data_realloc = data_realloc; - buf->data_free = data_free; - buf->buffer_free = buffer_free; -} - -void -hoedown_buffer_uninit(hoedown_buffer *buf) -{ - assert(buf && buf->unit); - buf->data_free(buf->data); -} - -hoedown_buffer * -hoedown_buffer_new(size_t unit) -{ - hoedown_buffer *ret = hoedown_malloc(sizeof (hoedown_buffer)); - hoedown_buffer_init(ret, unit, hoedown_realloc, free, free); - return ret; -} - -void -hoedown_buffer_free(hoedown_buffer *buf) -{ - if (!buf) return; - assert(buf && buf->unit); - - buf->data_free(buf->data); - - if (buf->buffer_free) - buf->buffer_free(buf); -} - -void -hoedown_buffer_reset(hoedown_buffer *buf) -{ - assert(buf && buf->unit); - - buf->data_free(buf->data); - buf->data = NULL; - buf->size = buf->asize = 0; -} - -void -hoedown_buffer_grow(hoedown_buffer *buf, size_t neosz) -{ - size_t neoasz; - assert(buf && buf->unit); - - if (buf->asize >= neosz) - return; - - neoasz = buf->asize + buf->unit; - while (neoasz < neosz) - neoasz += buf->unit; - - buf->data = buf->data_realloc(buf->data, neoasz); - buf->asize = neoasz; -} - -void -hoedown_buffer_put(hoedown_buffer *buf, const uint8_t *data, size_t size) -{ - assert(buf && buf->unit); - - if (buf->size + size > buf->asize) - hoedown_buffer_grow(buf, buf->size + size); - - memcpy(buf->data + buf->size, data, size); - buf->size += size; -} - -void -hoedown_buffer_puts(hoedown_buffer *buf, const char *str) -{ - hoedown_buffer_put(buf, (const uint8_t *)str, strlen(str)); -} - -void -hoedown_buffer_putc(hoedown_buffer *buf, uint8_t c) -{ - assert(buf && buf->unit); - - if (buf->size >= buf->asize) - hoedown_buffer_grow(buf, buf->size + 1); - - buf->data[buf->size] = c; - buf->size += 1; -} - -int -hoedown_buffer_putf(hoedown_buffer *buf, FILE *file) -{ - assert(buf && buf->unit); - - while (!(feof(file) || ferror(file))) { - hoedown_buffer_grow(buf, buf->size + buf->unit); - buf->size += fread(buf->data + buf->size, 1, buf->unit, file); - } - - return ferror(file); -} - -void -hoedown_buffer_set(hoedown_buffer *buf, const uint8_t *data, size_t size) -{ - assert(buf && buf->unit); - - if (size > buf->asize) - hoedown_buffer_grow(buf, size); - - memcpy(buf->data, data, size); - buf->size = size; -} - -void -hoedown_buffer_sets(hoedown_buffer *buf, const char *str) -{ - hoedown_buffer_set(buf, (const uint8_t *)str, strlen(str)); -} - -int -hoedown_buffer_eq(const hoedown_buffer *buf, const uint8_t *data, size_t size) -{ - if (buf->size != size) return 0; - return memcmp(buf->data, data, size) == 0; -} - -int -hoedown_buffer_eqs(const hoedown_buffer *buf, const char *str) -{ - return hoedown_buffer_eq(buf, (const uint8_t *)str, strlen(str)); -} - -int -hoedown_buffer_prefix(const hoedown_buffer *buf, const char *prefix) -{ - size_t i; - - for (i = 0; i < buf->size; ++i) { - if (prefix[i] == 0) - return 0; - - if (buf->data[i] != prefix[i]) - return buf->data[i] - prefix[i]; - } - - return 0; -} - -void -hoedown_buffer_slurp(hoedown_buffer *buf, size_t size) -{ - assert(buf && buf->unit); - - if (size >= buf->size) { - buf->size = 0; - return; - } - - buf->size -= size; - memmove(buf->data, buf->data + size, buf->size); -} - -const char * -hoedown_buffer_cstr(hoedown_buffer *buf) -{ - assert(buf && buf->unit); - - if (buf->size < buf->asize && buf->data[buf->size] == 0) - return (char *)buf->data; - - hoedown_buffer_grow(buf, buf->size + 1); - buf->data[buf->size] = 0; - - return (char *)buf->data; -} - -void -hoedown_buffer_printf(hoedown_buffer *buf, const char *fmt, ...) -{ - va_list ap; - int n; - - assert(buf && buf->unit); - - if (buf->size >= buf->asize) - hoedown_buffer_grow(buf, buf->size + 1); - - va_start(ap, fmt); - n = vsnprintf((char *)buf->data + buf->size, buf->asize - buf->size, fmt, ap); - va_end(ap); - - if (n < 0) { -#ifndef _MSC_VER - return; -#else - va_start(ap, fmt); - n = _vscprintf(fmt, ap); - va_end(ap); -#endif - } - - if ((size_t)n >= buf->asize - buf->size) { - hoedown_buffer_grow(buf, buf->size + n + 1); - - va_start(ap, fmt); - n = vsnprintf((char *)buf->data + buf->size, buf->asize - buf->size, fmt, ap); - va_end(ap); - } - - if (n < 0) - return; - - buf->size += n; -} - -void hoedown_buffer_put_utf8(hoedown_buffer *buf, unsigned int c) { - unsigned char unichar[4]; - - assert(buf && buf->unit); - - if (c < 0x80) { - hoedown_buffer_putc(buf, c); - } - else if (c < 0x800) { - unichar[0] = 192 + (c / 64); - unichar[1] = 128 + (c % 64); - hoedown_buffer_put(buf, unichar, 2); - } - else if (c - 0xd800u < 0x800) { - HOEDOWN_BUFPUTSL(buf, "\xef\xbf\xbd"); - } - else if (c < 0x10000) { - unichar[0] = 224 + (c / 4096); - unichar[1] = 128 + (c / 64) % 64; - unichar[2] = 128 + (c % 64); - hoedown_buffer_put(buf, unichar, 3); - } - else if (c < 0x110000) { - unichar[0] = 240 + (c / 262144); - unichar[1] = 128 + (c / 4096) % 64; - unichar[2] = 128 + (c / 64) % 64; - unichar[3] = 128 + (c % 64); - hoedown_buffer_put(buf, unichar, 4); - } - else { - HOEDOWN_BUFPUTSL(buf, "\xef\xbf\xbd"); - } -} diff --git a/Sources/CHoedown/document.c b/Sources/CHoedown/document.c deleted file mode 100644 index c088615..0000000 --- a/Sources/CHoedown/document.c +++ /dev/null @@ -1,2994 +0,0 @@ -#include "document.h" - -#include -#include -#include -#include - -#include "stack.h" - -#ifndef _MSC_VER -#include -#else -#define strncasecmp _strnicmp -#endif - -#define REF_TABLE_SIZE 8 - -#define BUFFER_BLOCK 0 -#define BUFFER_SPAN 1 - -#define HOEDOWN_LI_END 8 /* internal list flag */ - -const char *hoedown_find_block_tag(const char *str, unsigned int len); - -/*************** - * LOCAL TYPES * - ***************/ - -/* link_ref: reference to a link */ -struct link_ref { - unsigned int id; - - hoedown_buffer *link; - hoedown_buffer *title; - - struct link_ref *next; -}; - -/* footnote_ref: reference to a footnote */ -struct footnote_ref { - unsigned int id; - - int is_used; - unsigned int num; - - hoedown_buffer *contents; -}; - -/* footnote_item: an item in a footnote_list */ -struct footnote_item { - struct footnote_ref *ref; - struct footnote_item *next; -}; - -/* footnote_list: linked list of footnote_item */ -struct footnote_list { - unsigned int count; - struct footnote_item *head; - struct footnote_item *tail; -}; - -/* char_trigger: function pointer to render active chars */ -/* returns the number of chars taken care of */ -/* data is the pointer of the beginning of the span */ -/* offset is the number of valid chars before data */ -typedef size_t -(*char_trigger)(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); - -static size_t char_emphasis(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_quote(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_linebreak(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_codespan(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_escape(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_entity(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_langle_tag(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_autolink_url(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_autolink_email(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_autolink_www(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_link(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_superscript(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); -static size_t char_math(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size); - -enum markdown_char_t { - MD_CHAR_NONE = 0, - MD_CHAR_EMPHASIS, - MD_CHAR_CODESPAN, - MD_CHAR_LINEBREAK, - MD_CHAR_LINK, - MD_CHAR_LANGLE, - MD_CHAR_ESCAPE, - MD_CHAR_ENTITY, - MD_CHAR_AUTOLINK_URL, - MD_CHAR_AUTOLINK_EMAIL, - MD_CHAR_AUTOLINK_WWW, - MD_CHAR_SUPERSCRIPT, - MD_CHAR_QUOTE, - MD_CHAR_MATH -}; - -static char_trigger markdown_char_ptrs[] = { - NULL, - &char_emphasis, - &char_codespan, - &char_linebreak, - &char_link, - &char_langle_tag, - &char_escape, - &char_entity, - &char_autolink_url, - &char_autolink_email, - &char_autolink_www, - &char_superscript, - &char_quote, - &char_math -}; - -struct hoedown_document { - hoedown_renderer md; - hoedown_renderer_data data; - - struct link_ref *refs[REF_TABLE_SIZE]; - struct footnote_list footnotes_found; - struct footnote_list footnotes_used; - uint8_t active_char[256]; - hoedown_stack work_bufs[2]; - hoedown_extensions ext_flags; - size_t max_nesting; - int in_link_body; -}; - -/*************************** - * HELPER FUNCTIONS * - ***************************/ - -static hoedown_buffer * -newbuf(hoedown_document *doc, int type) -{ - static const size_t buf_size[2] = {256, 64}; - hoedown_buffer *work = NULL; - hoedown_stack *pool = &doc->work_bufs[type]; - - if (pool->size < pool->asize && - pool->item[pool->size] != NULL) { - work = pool->item[pool->size++]; - work->size = 0; - } else { - work = hoedown_buffer_new(buf_size[type]); - hoedown_stack_push(pool, work); - } - - return work; -} - -static void -popbuf(hoedown_document *doc, int type) -{ - doc->work_bufs[type].size--; -} - -static void -unscape_text(hoedown_buffer *ob, hoedown_buffer *src) -{ - size_t i = 0, org; - while (i < src->size) { - org = i; - while (i < src->size && src->data[i] != '\\') - i++; - - if (i > org) - hoedown_buffer_put(ob, src->data + org, i - org); - - if (i + 1 >= src->size) - break; - - hoedown_buffer_putc(ob, src->data[i + 1]); - i += 2; - } -} - -static unsigned int -hash_link_ref(const uint8_t *link_ref, size_t length) -{ - size_t i; - unsigned int hash = 0; - - for (i = 0; i < length; ++i) - hash = tolower(link_ref[i]) + (hash << 6) + (hash << 16) - hash; - - return hash; -} - -static struct link_ref * -add_link_ref( - struct link_ref **references, - const uint8_t *name, size_t name_size) -{ - struct link_ref *ref = hoedown_calloc(1, sizeof(struct link_ref)); - - ref->id = hash_link_ref(name, name_size); - ref->next = references[ref->id % REF_TABLE_SIZE]; - - references[ref->id % REF_TABLE_SIZE] = ref; - return ref; -} - -static struct link_ref * -find_link_ref(struct link_ref **references, uint8_t *name, size_t length) -{ - unsigned int hash = hash_link_ref(name, length); - struct link_ref *ref = NULL; - - ref = references[hash % REF_TABLE_SIZE]; - - while (ref != NULL) { - if (ref->id == hash) - return ref; - - ref = ref->next; - } - - return NULL; -} - -static void -free_link_refs(struct link_ref **references) -{ - size_t i; - - for (i = 0; i < REF_TABLE_SIZE; ++i) { - struct link_ref *r = references[i]; - struct link_ref *next; - - while (r) { - next = r->next; - hoedown_buffer_free(r->link); - hoedown_buffer_free(r->title); - free(r); - r = next; - } - } -} - -static struct footnote_ref * -create_footnote_ref(struct footnote_list *list, const uint8_t *name, size_t name_size) -{ - struct footnote_ref *ref = hoedown_calloc(1, sizeof(struct footnote_ref)); - - ref->id = hash_link_ref(name, name_size); - - return ref; -} - -static int -add_footnote_ref(struct footnote_list *list, struct footnote_ref *ref) -{ - struct footnote_item *item = hoedown_calloc(1, sizeof(struct footnote_item)); - if (!item) - return 0; - item->ref = ref; - - if (list->head == NULL) { - list->head = list->tail = item; - } else { - list->tail->next = item; - list->tail = item; - } - list->count++; - - return 1; -} - -static struct footnote_ref * -find_footnote_ref(struct footnote_list *list, uint8_t *name, size_t length) -{ - unsigned int hash = hash_link_ref(name, length); - struct footnote_item *item = NULL; - - item = list->head; - - while (item != NULL) { - if (item->ref->id == hash) - return item->ref; - item = item->next; - } - - return NULL; -} - -static void -free_footnote_ref(struct footnote_ref *ref) -{ - hoedown_buffer_free(ref->contents); - free(ref); -} - -static void -free_footnote_list(struct footnote_list *list, int free_refs) -{ - struct footnote_item *item = list->head; - struct footnote_item *next; - - while (item) { - next = item->next; - if (free_refs) - free_footnote_ref(item->ref); - free(item); - item = next; - } -} - - -/* - * Check whether a char is a Markdown spacing char. - - * Right now we only consider spaces the actual - * space and a newline: tabs and carriage returns - * are filtered out during the preprocessing phase. - * - * If we wanted to actually be UTF-8 compliant, we - * should instead extract an Unicode codepoint from - * this character and check for space properties. - */ -static int -_isspace(int c) -{ - return c == ' ' || c == '\n'; -} - -/* is_empty_all: verify that all the data is spacing */ -static int -is_empty_all(const uint8_t *data, size_t size) -{ - size_t i = 0; - while (i < size && _isspace(data[i])) i++; - return i == size; -} - -/* - * Replace all spacing characters in data with spaces. As a special - * case, this collapses a newline with the previous space, if possible. - */ -static void -replace_spacing(hoedown_buffer *ob, const uint8_t *data, size_t size) -{ - size_t i = 0, mark; - hoedown_buffer_grow(ob, size); - while (1) { - mark = i; - while (i < size && data[i] != '\n') i++; - hoedown_buffer_put(ob, data + mark, i - mark); - - if (i >= size) break; - - if (!(i > 0 && data[i-1] == ' ')) - hoedown_buffer_putc(ob, ' '); - i++; - } -} - -/**************************** - * INLINE PARSING FUNCTIONS * - ****************************/ - -/* is_mail_autolink • looks for the address part of a mail autolink and '>' */ -/* this is less strict than the original markdown e-mail address matching */ -static size_t -is_mail_autolink(uint8_t *data, size_t size) -{ - size_t i = 0, nb = 0; - - /* address is assumed to be: [-@._a-zA-Z0-9]+ with exactly one '@' */ - for (i = 0; i < size; ++i) { - if (isalnum(data[i])) - continue; - - switch (data[i]) { - case '@': - nb++; - - case '-': - case '.': - case '_': - break; - - case '>': - return (nb == 1) ? i + 1 : 0; - - default: - return 0; - } - } - - return 0; -} - -/* tag_length • returns the length of the given tag, or 0 is it's not valid */ -static size_t -tag_length(uint8_t *data, size_t size, hoedown_autolink_type *autolink) -{ - size_t i, j; - - /* a valid tag can't be shorter than 3 chars */ - if (size < 3) return 0; - - if (data[0] != '<') return 0; - - /* HTML comment, laxist form */ - if (size > 5 && data[1] == '!' && data[2] == '-' && data[3] == '-') { - i = 5; - - while (i < size && !(data[i - 2] == '-' && data[i - 1] == '-' && data[i] == '>')) - i++; - - i++; - - if (i <= size) - return i; - } - - /* begins with a '<' optionally followed by '/', followed by letter or number */ - i = (data[1] == '/') ? 2 : 1; - - if (!isalnum(data[i])) - return 0; - - /* scheme test */ - *autolink = HOEDOWN_AUTOLINK_NONE; - - /* try to find the beginning of an URI */ - while (i < size && (isalnum(data[i]) || data[i] == '.' || data[i] == '+' || data[i] == '-')) - i++; - - if (i > 1 && data[i] == '@') { - if ((j = is_mail_autolink(data + i, size - i)) != 0) { - *autolink = HOEDOWN_AUTOLINK_EMAIL; - return i + j; - } - } - - if (i > 2 && data[i] == ':') { - *autolink = HOEDOWN_AUTOLINK_NORMAL; - i++; - } - - /* completing autolink test: no spacing or ' or " */ - if (i >= size) - *autolink = HOEDOWN_AUTOLINK_NONE; - - else if (*autolink) { - j = i; - - while (i < size) { - if (data[i] == '\\') i += 2; - else if (data[i] == '>' || data[i] == '\'' || - data[i] == '"' || data[i] == ' ' || data[i] == '\n') - break; - else i++; - } - - if (i >= size) return 0; - if (i > j && data[i] == '>') return i + 1; - /* one of the forbidden chars has been found */ - *autolink = HOEDOWN_AUTOLINK_NONE; - } - - /* looking for something looking like a tag end */ - while (i < size && data[i] != '>') i++; - if (i >= size) return 0; - return i + 1; -} - -/* parse_inline • parses inline markdown elements */ -static void -parse_inline(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size) -{ - size_t i = 0, end = 0, consumed = 0; - hoedown_buffer work = { 0, 0, 0, 0, NULL, NULL, NULL }; - uint8_t *active_char = doc->active_char; - - if (doc->work_bufs[BUFFER_SPAN].size + - doc->work_bufs[BUFFER_BLOCK].size > doc->max_nesting) - return; - - while (i < size) { - /* copying inactive chars into the output */ - while (end < size && active_char[data[end]] == 0) - end++; - - if (doc->md.normal_text) { - work.data = data + i; - work.size = end - i; - doc->md.normal_text(ob, &work, &doc->data); - } - else - hoedown_buffer_put(ob, data + i, end - i); - - if (end >= size) break; - i = end; - - end = markdown_char_ptrs[ (int)active_char[data[end]] ](ob, doc, data + i, i - consumed, size - i); - if (!end) /* no action from the callback */ - end = i + 1; - else { - i += end; - end = i; - consumed = i; - } - } -} - -/* is_escaped • returns whether special char at data[loc] is escaped by '\\' */ -static int -is_escaped(uint8_t *data, size_t loc) -{ - size_t i = loc; - while (i >= 1 && data[i - 1] == '\\') - i--; - - /* odd numbers of backslashes escapes data[loc] */ - return (loc - i) % 2; -} - -/* find_emph_char • looks for the next emph uint8_t, skipping other constructs */ -static size_t -find_emph_char(uint8_t *data, size_t size, uint8_t c) -{ - size_t i = 0; - - while (i < size) { - while (i < size && data[i] != c && data[i] != '[' && data[i] != '`') - i++; - - if (i == size) - return 0; - - /* not counting escaped chars */ - if (is_escaped(data, i)) { - i++; continue; - } - - if (data[i] == c) - return i; - - /* skipping a codespan */ - if (data[i] == '`') { - size_t span_nb = 0, bt; - size_t tmp_i = 0; - - /* counting the number of opening backticks */ - while (i < size && data[i] == '`') { - i++; span_nb++; - } - - if (i >= size) return 0; - - /* finding the matching closing sequence */ - bt = 0; - while (i < size && bt < span_nb) { - if (!tmp_i && data[i] == c) tmp_i = i; - if (data[i] == '`') bt++; - else bt = 0; - i++; - } - - /* not a well-formed codespan; use found matching emph char */ - if (bt < span_nb && i >= size) return tmp_i; - } - /* skipping a link */ - else if (data[i] == '[') { - size_t tmp_i = 0; - uint8_t cc; - - i++; - while (i < size && data[i] != ']') { - if (!tmp_i && data[i] == c) tmp_i = i; - i++; - } - - i++; - while (i < size && _isspace(data[i])) - i++; - - if (i >= size) - return tmp_i; - - switch (data[i]) { - case '[': - cc = ']'; break; - - case '(': - cc = ')'; break; - - default: - if (tmp_i) - return tmp_i; - else - continue; - } - - i++; - while (i < size && data[i] != cc) { - if (!tmp_i && data[i] == c) tmp_i = i; - i++; - } - - if (i >= size) - return tmp_i; - - i++; - } - } - - return 0; -} - -/* parse_emph1 • parsing single emphase */ -/* closed by a symbol not preceded by spacing and not followed by symbol */ -static size_t -parse_emph1(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size, uint8_t c) -{ - size_t i = 0, len; - hoedown_buffer *work = 0; - int r; - - /* skipping one symbol if coming from emph3 */ - if (size > 1 && data[0] == c && data[1] == c) i = 1; - - while (i < size) { - len = find_emph_char(data + i, size - i, c); - if (!len) return 0; - i += len; - if (i >= size) return 0; - - if (data[i] == c && !_isspace(data[i - 1])) { - - if (doc->ext_flags & HOEDOWN_EXT_NO_INTRA_EMPHASIS) { - if (i + 1 < size && isalnum(data[i + 1])) - continue; - } - - work = newbuf(doc, BUFFER_SPAN); - parse_inline(work, doc, data, i); - - if (doc->ext_flags & HOEDOWN_EXT_UNDERLINE && c == '_') - r = doc->md.underline(ob, work, &doc->data); - else - r = doc->md.emphasis(ob, work, &doc->data); - - popbuf(doc, BUFFER_SPAN); - return r ? i + 1 : 0; - } - } - - return 0; -} - -/* parse_emph2 • parsing single emphase */ -static size_t -parse_emph2(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size, uint8_t c) -{ - size_t i = 0, len; - hoedown_buffer *work = 0; - int r; - - while (i < size) { - len = find_emph_char(data + i, size - i, c); - if (!len) return 0; - i += len; - - if (i + 1 < size && data[i] == c && data[i + 1] == c && i && !_isspace(data[i - 1])) { - work = newbuf(doc, BUFFER_SPAN); - parse_inline(work, doc, data, i); - - if (c == '~') - r = doc->md.strikethrough(ob, work, &doc->data); - else if (c == '=') - r = doc->md.highlight(ob, work, &doc->data); - else - r = doc->md.double_emphasis(ob, work, &doc->data); - - popbuf(doc, BUFFER_SPAN); - return r ? i + 2 : 0; - } - i++; - } - return 0; -} - -/* parse_emph3 • parsing single emphase */ -/* finds the first closing tag, and delegates to the other emph */ -static size_t -parse_emph3(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size, uint8_t c) -{ - size_t i = 0, len; - int r; - - while (i < size) { - len = find_emph_char(data + i, size - i, c); - if (!len) return 0; - i += len; - - /* skip spacing preceded symbols */ - if (data[i] != c || _isspace(data[i - 1])) - continue; - - if (i + 2 < size && data[i + 1] == c && data[i + 2] == c && doc->md.triple_emphasis) { - /* triple symbol found */ - hoedown_buffer *work = newbuf(doc, BUFFER_SPAN); - - parse_inline(work, doc, data, i); - r = doc->md.triple_emphasis(ob, work, &doc->data); - popbuf(doc, BUFFER_SPAN); - return r ? i + 3 : 0; - - } else if (i + 1 < size && data[i + 1] == c) { - /* double symbol found, handing over to emph1 */ - len = parse_emph1(ob, doc, data - 2, size + 2, c); - if (!len) return 0; - else return len - 2; - - } else { - /* single symbol found, handing over to emph2 */ - len = parse_emph2(ob, doc, data - 1, size + 1, c); - if (!len) return 0; - else return len - 1; - } - } - return 0; -} - -/* parse_math • parses a math span until the given ending delimiter */ -static size_t -parse_math(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size, const char *end, size_t delimsz, int displaymode) -{ - hoedown_buffer text = { NULL, 0, 0, 0, NULL, NULL, NULL }; - size_t i = delimsz; - - if (!doc->md.math) - return 0; - - /* find ending delimiter */ - while (1) { - while (i < size && data[i] != (uint8_t)end[0]) - i++; - - if (i >= size) - return 0; - - if (!is_escaped(data, i) && !(i + delimsz > size) - && memcmp(data + i, end, delimsz) == 0) - break; - - i++; - } - - /* prepare buffers */ - text.data = data + delimsz; - text.size = i - delimsz; - - /* if this is a $$ and MATH_EXPLICIT is not active, - * guess whether displaymode should be enabled from the context */ - i += delimsz; - if (delimsz == 2 && !(doc->ext_flags & HOEDOWN_EXT_MATH_EXPLICIT)) - displaymode = is_empty_all(data - offset, offset) && is_empty_all(data + i, size - i); - - /* call callback */ - if (doc->md.math(ob, &text, displaymode, &doc->data)) - return i; - - return 0; -} - -/* char_emphasis • single and double emphasis parsing */ -static size_t -char_emphasis(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - uint8_t c = data[0]; - size_t ret; - - if (doc->ext_flags & HOEDOWN_EXT_NO_INTRA_EMPHASIS) { - if (offset > 0 && !_isspace(data[-1]) && data[-1] != '>' && data[-1] != '(') - return 0; - } - - if (size > 2 && data[1] != c) { - /* spacing cannot follow an opening emphasis; - * strikethrough and highlight only takes two characters '~~' */ - if (c == '~' || c == '=' || _isspace(data[1]) || (ret = parse_emph1(ob, doc, data + 1, size - 1, c)) == 0) - return 0; - - return ret + 1; - } - - if (size > 3 && data[1] == c && data[2] != c) { - if (_isspace(data[2]) || (ret = parse_emph2(ob, doc, data + 2, size - 2, c)) == 0) - return 0; - - return ret + 2; - } - - if (size > 4 && data[1] == c && data[2] == c && data[3] != c) { - if (c == '~' || c == '=' || _isspace(data[3]) || (ret = parse_emph3(ob, doc, data + 3, size - 3, c)) == 0) - return 0; - - return ret + 3; - } - - return 0; -} - - -/* char_linebreak • '\n' preceded by two spaces (assuming linebreak != 0) */ -static size_t -char_linebreak(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - if (offset < 2 || data[-1] != ' ' || data[-2] != ' ') - return 0; - - /* removing the last space from ob and rendering */ - while (ob->size && ob->data[ob->size - 1] == ' ') - ob->size--; - - return doc->md.linebreak(ob, &doc->data) ? 1 : 0; -} - - -/* char_codespan • '`' parsing a code span (assuming codespan != 0) */ -static size_t -char_codespan(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - hoedown_buffer work = { NULL, 0, 0, 0, NULL, NULL, NULL }; - size_t end, nb = 0, i, f_begin, f_end; - - /* counting the number of backticks in the delimiter */ - while (nb < size && data[nb] == '`') - nb++; - - /* finding the next delimiter */ - i = 0; - for (end = nb; end < size && i < nb; end++) { - if (data[end] == '`') i++; - else i = 0; - } - - if (i < nb && end >= size) - return 0; /* no matching delimiter */ - - /* trimming outside spaces */ - f_begin = nb; - while (f_begin < end && data[f_begin] == ' ') - f_begin++; - - f_end = end - nb; - while (f_end > nb && data[f_end-1] == ' ') - f_end--; - - /* real code span */ - if (f_begin < f_end) { - work.data = data + f_begin; - work.size = f_end - f_begin; - - if (!doc->md.codespan(ob, &work, &doc->data)) - end = 0; - } else { - if (!doc->md.codespan(ob, 0, &doc->data)) - end = 0; - } - - return end; -} - -/* char_quote • '"' parsing a quote */ -static size_t -char_quote(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - size_t end, nq = 0, i, f_begin, f_end; - - /* counting the number of quotes in the delimiter */ - while (nq < size && data[nq] == '"') - nq++; - - /* finding the next delimiter */ - end = nq; - while (1) { - i = end; - end += find_emph_char(data + end, size - end, '"'); - if (end == i) return 0; /* no matching delimiter */ - i = end; - while (end < size && data[end] == '"' && end - i < nq) end++; - if (end - i >= nq) break; - } - - /* trimming outside spaces */ - f_begin = nq; - while (f_begin < end && data[f_begin] == ' ') - f_begin++; - - f_end = end - nq; - while (f_end > nq && data[f_end-1] == ' ') - f_end--; - - /* real quote */ - if (f_begin < f_end) { - hoedown_buffer *work = newbuf(doc, BUFFER_SPAN); - parse_inline(work, doc, data + f_begin, f_end - f_begin); - - if (!doc->md.quote(ob, work, &doc->data)) - end = 0; - popbuf(doc, BUFFER_SPAN); - } else { - if (!doc->md.quote(ob, 0, &doc->data)) - end = 0; - } - - return end; -} - - -/* char_escape • '\\' backslash escape */ -static size_t -char_escape(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - static const char *escape_chars = "\\`*_{}[]()#+-.!:|&<>^~=\"$"; - hoedown_buffer work = { 0, 0, 0, 0, NULL, NULL, NULL }; - size_t w; - - if (size > 1) { - if (data[1] == '\\' && (doc->ext_flags & HOEDOWN_EXT_MATH) && - size > 2 && (data[2] == '(' || data[2] == '[')) { - const char *end = (data[2] == '[') ? "\\\\]" : "\\\\)"; - w = parse_math(ob, doc, data, offset, size, end, 3, data[2] == '['); - if (w) return w; - } - - if (strchr(escape_chars, data[1]) == NULL) - return 0; - - if (doc->md.normal_text) { - work.data = data + 1; - work.size = 1; - doc->md.normal_text(ob, &work, &doc->data); - } - else hoedown_buffer_putc(ob, data[1]); - } else if (size == 1) { - hoedown_buffer_putc(ob, data[0]); - } - - return 2; -} - -/* char_entity • '&' escaped when it doesn't belong to an entity */ -/* valid entities are assumed to be anything matching &#?[A-Za-z0-9]+; */ -static size_t -char_entity(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - size_t end = 1; - hoedown_buffer work = { 0, 0, 0, 0, NULL, NULL, NULL }; - - if (end < size && data[end] == '#') - end++; - - while (end < size && isalnum(data[end])) - end++; - - if (end < size && data[end] == ';') - end++; /* real entity */ - else - return 0; /* lone '&' */ - - if (doc->md.entity) { - work.data = data; - work.size = end; - doc->md.entity(ob, &work, &doc->data); - } - else hoedown_buffer_put(ob, data, end); - - return end; -} - -/* char_langle_tag • '<' when tags or autolinks are allowed */ -static size_t -char_langle_tag(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - hoedown_buffer work = { NULL, 0, 0, 0, NULL, NULL, NULL }; - hoedown_autolink_type altype = HOEDOWN_AUTOLINK_NONE; - size_t end = tag_length(data, size, &altype); - int ret = 0; - - work.data = data; - work.size = end; - - if (end > 2) { - if (doc->md.autolink && altype != HOEDOWN_AUTOLINK_NONE) { - hoedown_buffer *u_link = newbuf(doc, BUFFER_SPAN); - work.data = data + 1; - work.size = end - 2; - unscape_text(u_link, &work); - ret = doc->md.autolink(ob, u_link, altype, &doc->data); - popbuf(doc, BUFFER_SPAN); - } - else if (doc->md.raw_html) - ret = doc->md.raw_html(ob, &work, &doc->data); - } - - if (!ret) return 0; - else return end; -} - -static size_t -char_autolink_www(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - hoedown_buffer *link, *link_url, *link_text; - size_t link_len, rewind; - - if (!doc->md.link || doc->in_link_body) - return 0; - - link = newbuf(doc, BUFFER_SPAN); - - if ((link_len = hoedown_autolink__www(&rewind, link, data, offset, size, HOEDOWN_AUTOLINK_SHORT_DOMAINS)) > 0) { - link_url = newbuf(doc, BUFFER_SPAN); - HOEDOWN_BUFPUTSL(link_url, "http://"); - hoedown_buffer_put(link_url, link->data, link->size); - - if (ob->size > rewind) - ob->size -= rewind; - else - ob->size = 0; - - if (doc->md.normal_text) { - link_text = newbuf(doc, BUFFER_SPAN); - doc->md.normal_text(link_text, link, &doc->data); - doc->md.link(ob, link_text, link_url, NULL, &doc->data); - popbuf(doc, BUFFER_SPAN); - } else { - doc->md.link(ob, link, link_url, NULL, &doc->data); - } - popbuf(doc, BUFFER_SPAN); - } - - popbuf(doc, BUFFER_SPAN); - return link_len; -} - -static size_t -char_autolink_email(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - hoedown_buffer *link; - size_t link_len, rewind; - - if (!doc->md.autolink || doc->in_link_body) - return 0; - - link = newbuf(doc, BUFFER_SPAN); - - if ((link_len = hoedown_autolink__email(&rewind, link, data, offset, size, 0)) > 0) { - if (ob->size > rewind) - ob->size -= rewind; - else - ob->size = 0; - - doc->md.autolink(ob, link, HOEDOWN_AUTOLINK_EMAIL, &doc->data); - } - - popbuf(doc, BUFFER_SPAN); - return link_len; -} - -static size_t -char_autolink_url(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - hoedown_buffer *link; - size_t link_len, rewind; - - if (!doc->md.autolink || doc->in_link_body) - return 0; - - link = newbuf(doc, BUFFER_SPAN); - - if ((link_len = hoedown_autolink__url(&rewind, link, data, offset, size, 0)) > 0) { - if (ob->size > rewind) - ob->size -= rewind; - else - ob->size = 0; - - doc->md.autolink(ob, link, HOEDOWN_AUTOLINK_NORMAL, &doc->data); - } - - popbuf(doc, BUFFER_SPAN); - return link_len; -} - -/* char_link • '[': parsing a link, a footnote or an image */ -static size_t -char_link(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - int is_img = (offset && data[-1] == '!' && !is_escaped(data - offset, offset - 1)); - int is_footnote = (doc->ext_flags & HOEDOWN_EXT_FOOTNOTES && data[1] == '^'); - size_t i = 1, txt_e, link_b = 0, link_e = 0, title_b = 0, title_e = 0; - hoedown_buffer *content = NULL; - hoedown_buffer *link = NULL; - hoedown_buffer *title = NULL; - hoedown_buffer *u_link = NULL; - size_t org_work_size = doc->work_bufs[BUFFER_SPAN].size; - int ret = 0, in_title = 0, qtype = 0; - - /* checking whether the correct renderer exists */ - if ((is_footnote && !doc->md.footnote_ref) || (is_img && !doc->md.image) - || (!is_img && !is_footnote && !doc->md.link)) - goto cleanup; - - /* looking for the matching closing bracket */ - i += find_emph_char(data + i, size - i, ']'); - txt_e = i; - - if (i < size && data[i] == ']') i++; - else goto cleanup; - - /* footnote link */ - if (is_footnote) { - hoedown_buffer id = { NULL, 0, 0, 0, NULL, NULL, NULL }; - struct footnote_ref *fr; - - if (txt_e < 3) - goto cleanup; - - id.data = data + 2; - id.size = txt_e - 2; - - fr = find_footnote_ref(&doc->footnotes_found, id.data, id.size); - - /* mark footnote used */ - if (fr && !fr->is_used) { - if(!add_footnote_ref(&doc->footnotes_used, fr)) - goto cleanup; - fr->is_used = 1; - fr->num = doc->footnotes_used.count; - - /* render */ - if (doc->md.footnote_ref) - ret = doc->md.footnote_ref(ob, fr->num, &doc->data); - } - - goto cleanup; - } - - /* skip any amount of spacing */ - /* (this is much more laxist than original markdown syntax) */ - while (i < size && _isspace(data[i])) - i++; - - /* inline style link */ - if (i < size && data[i] == '(') { - size_t nb_p; - - /* skipping initial spacing */ - i++; - - while (i < size && _isspace(data[i])) - i++; - - link_b = i; - - /* looking for link end: ' " ) */ - /* Count the number of open parenthesis */ - nb_p = 0; - - while (i < size) { - if (data[i] == '\\') i += 2; - else if (data[i] == '(' && i != 0) { - nb_p++; i++; - } - else if (data[i] == ')') { - if (nb_p == 0) break; - else nb_p--; i++; - } else if (i >= 1 && _isspace(data[i-1]) && (data[i] == '\'' || data[i] == '"')) break; - else i++; - } - - if (i >= size) goto cleanup; - link_e = i; - - /* looking for title end if present */ - if (data[i] == '\'' || data[i] == '"') { - qtype = data[i]; - in_title = 1; - i++; - title_b = i; - - while (i < size) { - if (data[i] == '\\') i += 2; - else if (data[i] == qtype) {in_title = 0; i++;} - else if ((data[i] == ')') && !in_title) break; - else i++; - } - - if (i >= size) goto cleanup; - - /* skipping spacing after title */ - title_e = i - 1; - while (title_e > title_b && _isspace(data[title_e])) - title_e--; - - /* checking for closing quote presence */ - if (data[title_e] != '\'' && data[title_e] != '"') { - title_b = title_e = 0; - link_e = i; - } - } - - /* remove spacing at the end of the link */ - while (link_e > link_b && _isspace(data[link_e - 1])) - link_e--; - - /* remove optional angle brackets around the link */ - if (data[link_b] == '<' && data[link_e - 1] == '>') { - link_b++; - link_e--; - } - - /* building escaped link and title */ - if (link_e > link_b) { - link = newbuf(doc, BUFFER_SPAN); - hoedown_buffer_put(link, data + link_b, link_e - link_b); - } - - if (title_e > title_b) { - title = newbuf(doc, BUFFER_SPAN); - hoedown_buffer_put(title, data + title_b, title_e - title_b); - } - - i++; - } - - /* reference style link */ - else if (i < size && data[i] == '[') { - hoedown_buffer *id = newbuf(doc, BUFFER_SPAN); - struct link_ref *lr; - - /* looking for the id */ - i++; - link_b = i; - while (i < size && data[i] != ']') i++; - if (i >= size) goto cleanup; - link_e = i; - - /* finding the link_ref */ - if (link_b == link_e) - replace_spacing(id, data + 1, txt_e - 1); - else - hoedown_buffer_put(id, data + link_b, link_e - link_b); - - lr = find_link_ref(doc->refs, id->data, id->size); - if (!lr) - goto cleanup; - - /* keeping link and title from link_ref */ - link = lr->link; - title = lr->title; - i++; - } - - /* shortcut reference style link */ - else { - hoedown_buffer *id = newbuf(doc, BUFFER_SPAN); - struct link_ref *lr; - - /* crafting the id */ - replace_spacing(id, data + 1, txt_e - 1); - - /* finding the link_ref */ - lr = find_link_ref(doc->refs, id->data, id->size); - if (!lr) - goto cleanup; - - /* keeping link and title from link_ref */ - link = lr->link; - title = lr->title; - - /* rewinding the spacing */ - i = txt_e + 1; - } - - /* building content: img alt is kept, only link content is parsed */ - if (txt_e > 1) { - content = newbuf(doc, BUFFER_SPAN); - if (is_img) { - hoedown_buffer_put(content, data + 1, txt_e - 1); - } else { - /* disable autolinking when parsing inline the - * content of a link */ - doc->in_link_body = 1; - parse_inline(content, doc, data + 1, txt_e - 1); - doc->in_link_body = 0; - } - } - - if (link) { - u_link = newbuf(doc, BUFFER_SPAN); - unscape_text(u_link, link); - } - - /* calling the relevant rendering function */ - if (is_img) { - if (ob->size && ob->data[ob->size - 1] == '!') - ob->size -= 1; - - ret = doc->md.image(ob, u_link, title, content, &doc->data); - } else { - ret = doc->md.link(ob, content, u_link, title, &doc->data); - } - - /* cleanup */ -cleanup: - doc->work_bufs[BUFFER_SPAN].size = (int)org_work_size; - return ret ? i : 0; -} - -static size_t -char_superscript(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - size_t sup_start, sup_len; - hoedown_buffer *sup; - - if (!doc->md.superscript) - return 0; - - if (size < 2) - return 0; - - if (data[1] == '(') { - sup_start = 2; - sup_len = find_emph_char(data + 2, size - 2, ')') + 2; - - if (sup_len == size) - return 0; - } else { - sup_start = sup_len = 1; - - while (sup_len < size && !_isspace(data[sup_len])) - sup_len++; - } - - if (sup_len - sup_start == 0) - return (sup_start == 2) ? 3 : 0; - - sup = newbuf(doc, BUFFER_SPAN); - parse_inline(sup, doc, data + sup_start, sup_len - sup_start); - doc->md.superscript(ob, sup, &doc->data); - popbuf(doc, BUFFER_SPAN); - - return (sup_start == 2) ? sup_len + 1 : sup_len; -} - -static size_t -char_math(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) -{ - /* double dollar */ - if (size > 1 && data[1] == '$') - return parse_math(ob, doc, data, offset, size, "$$", 2, 1); - - /* single dollar allowed only with MATH_EXPLICIT flag */ - if (doc->ext_flags & HOEDOWN_EXT_MATH_EXPLICIT) - return parse_math(ob, doc, data, offset, size, "$", 1, 0); - - return 0; -} - -/********************************* - * BLOCK-LEVEL PARSING FUNCTIONS * - *********************************/ - -/* is_empty • returns the line length when it is empty, 0 otherwise */ -static size_t -is_empty(const uint8_t *data, size_t size) -{ - size_t i; - - for (i = 0; i < size && data[i] != '\n'; i++) - if (data[i] != ' ') - return 0; - - return i + 1; -} - -/* is_hrule • returns whether a line is a horizontal rule */ -static int -is_hrule(uint8_t *data, size_t size) -{ - size_t i = 0, n = 0; - uint8_t c; - - /* skipping initial spaces */ - if (size < 3) return 0; - if (data[0] == ' ') { i++; - if (data[1] == ' ') { i++; - if (data[2] == ' ') { i++; } } } - - /* looking at the hrule uint8_t */ - if (i + 2 >= size - || (data[i] != '*' && data[i] != '-' && data[i] != '_')) - return 0; - c = data[i]; - - /* the whole line must be the char or space */ - while (i < size && data[i] != '\n') { - if (data[i] == c) n++; - else if (data[i] != ' ') - return 0; - - i++; - } - - return n >= 3; -} - -/* check if a line is a code fence; return the - * end of the code fence. if passed, width of - * the fence rule and character will be returned */ -static size_t -is_codefence(uint8_t *data, size_t size, size_t *width, uint8_t *chr) -{ - size_t i = 0, n = 1; - uint8_t c; - - /* skipping initial spaces */ - if (size < 3) - return 0; - - if (data[0] == ' ') { i++; - if (data[1] == ' ') { i++; - if (data[2] == ' ') { i++; } } } - - /* looking at the hrule uint8_t */ - c = data[i]; - if (i + 2 >= size || !(c=='~' || c=='`')) - return 0; - - /* the fence must be that same character */ - while (++i < size && data[i] == c) - ++n; - - if (n < 3) - return 0; - - if (width) *width = n; - if (chr) *chr = c; - return i; -} - -/* expects single line, checks if it's a codefence and extracts language */ -static size_t -parse_codefence(uint8_t *data, size_t size, hoedown_buffer *lang, size_t *width, uint8_t *chr) -{ - size_t i, w, lang_start; - - i = w = is_codefence(data, size, width, chr); - if (i == 0) - return 0; - - while (i < size && _isspace(data[i])) - i++; - - lang_start = i; - - while (i < size && !_isspace(data[i])) - i++; - - lang->data = data + lang_start; - lang->size = i - lang_start; - - /* Avoid parsing a codespan as a fence */ - i = lang_start + 2; - while (i < size && !(data[i] == *chr && data[i-1] == *chr && data[i-2] == *chr)) i++; - if (i < size) return 0; - - return w; -} - -/* is_atxheader • returns whether the line is a hash-prefixed header */ -static int -is_atxheader(hoedown_document *doc, uint8_t *data, size_t size) -{ - if (data[0] != '#') - return 0; - - if (doc->ext_flags & HOEDOWN_EXT_SPACE_HEADERS) { - size_t level = 0; - - while (level < size && level < 6 && data[level] == '#') - level++; - - if (level < size && data[level] != ' ') - return 0; - } - - return 1; -} - -/* is_headerline • returns whether the line is a setext-style hdr underline */ -static int -is_headerline(uint8_t *data, size_t size) -{ - size_t i = 0; - - /* test of level 1 header */ - if (data[i] == '=') { - for (i = 1; i < size && data[i] == '='; i++); - while (i < size && data[i] == ' ') i++; - return (i >= size || data[i] == '\n') ? 1 : 0; } - - /* test of level 2 header */ - if (data[i] == '-') { - for (i = 1; i < size && data[i] == '-'; i++); - while (i < size && data[i] == ' ') i++; - return (i >= size || data[i] == '\n') ? 2 : 0; } - - return 0; -} - -static int -is_next_headerline(uint8_t *data, size_t size) -{ - size_t i = 0; - - while (i < size && data[i] != '\n') - i++; - - if (++i >= size) - return 0; - - return is_headerline(data + i, size - i); -} - -/* prefix_quote • returns blockquote prefix length */ -static size_t -prefix_quote(uint8_t *data, size_t size) -{ - size_t i = 0; - if (i < size && data[i] == ' ') i++; - if (i < size && data[i] == ' ') i++; - if (i < size && data[i] == ' ') i++; - - if (i < size && data[i] == '>') { - if (i + 1 < size && data[i + 1] == ' ') - return i + 2; - - return i + 1; - } - - return 0; -} - -/* prefix_code • returns prefix length for block code*/ -static size_t -prefix_code(uint8_t *data, size_t size) -{ - if (size > 3 && data[0] == ' ' && data[1] == ' ' - && data[2] == ' ' && data[3] == ' ') return 4; - - return 0; -} - -/* prefix_oli • returns ordered list item prefix */ -static size_t -prefix_oli(uint8_t *data, size_t size) -{ - size_t i = 0; - - if (i < size && data[i] == ' ') i++; - if (i < size && data[i] == ' ') i++; - if (i < size && data[i] == ' ') i++; - - if (i >= size || data[i] < '0' || data[i] > '9') - return 0; - - while (i < size && data[i] >= '0' && data[i] <= '9') - i++; - - if (i + 1 >= size || data[i] != '.' || data[i + 1] != ' ') - return 0; - - if (is_next_headerline(data + i, size - i)) - return 0; - - return i + 2; -} - -/* prefix_uli • returns ordered list item prefix */ -static size_t -prefix_uli(uint8_t *data, size_t size) -{ - size_t i = 0; - - if (i < size && data[i] == ' ') i++; - if (i < size && data[i] == ' ') i++; - if (i < size && data[i] == ' ') i++; - - if (i + 1 >= size || - (data[i] != '*' && data[i] != '+' && data[i] != '-') || - data[i + 1] != ' ') - return 0; - - if (is_next_headerline(data + i, size - i)) - return 0; - - return i + 2; -} - - -/* parse_block • parsing of one block, returning next uint8_t to parse */ -static void parse_block(hoedown_buffer *ob, hoedown_document *doc, - uint8_t *data, size_t size); - - -/* parse_blockquote • handles parsing of a blockquote fragment */ -static size_t -parse_blockquote(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size) -{ - size_t beg, end = 0, pre, work_size = 0; - uint8_t *work_data = 0; - hoedown_buffer *out = 0; - - out = newbuf(doc, BUFFER_BLOCK); - beg = 0; - while (beg < size) { - for (end = beg + 1; end < size && data[end - 1] != '\n'; end++); - - pre = prefix_quote(data + beg, end - beg); - - if (pre) - beg += pre; /* skipping prefix */ - - /* empty line followed by non-quote line */ - else if (is_empty(data + beg, end - beg) && - (end >= size || (prefix_quote(data + end, size - end) == 0 && - !is_empty(data + end, size - end)))) - break; - - if (beg < end) { /* copy into the in-place working buffer */ - /* hoedown_buffer_put(work, data + beg, end - beg); */ - if (!work_data) - work_data = data + beg; - else if (data + beg != work_data + work_size) - memmove(work_data + work_size, data + beg, end - beg); - work_size += end - beg; - } - beg = end; - } - - parse_block(out, doc, work_data, work_size); - if (doc->md.blockquote) - doc->md.blockquote(ob, out, &doc->data); - popbuf(doc, BUFFER_BLOCK); - return end; -} - -static size_t -parse_htmlblock(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size, int do_render); - -/* parse_blockquote • handles parsing of a regular paragraph */ -static size_t -parse_paragraph(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size) -{ - hoedown_buffer work = { NULL, 0, 0, 0, NULL, NULL, NULL }; - size_t i = 0, end = 0; - int level = 0; - - work.data = data; - - while (i < size) { - for (end = i + 1; end < size && data[end - 1] != '\n'; end++) /* empty */; - - if (is_empty(data + i, size - i)) - break; - - if ((level = is_headerline(data + i, size - i)) != 0) - break; - - if (is_atxheader(doc, data + i, size - i) || - is_hrule(data + i, size - i) || - prefix_quote(data + i, size - i)) { - end = i; - break; - } - - i = end; - } - - work.size = i; - while (work.size && data[work.size - 1] == '\n') - work.size--; - - if (!level) { - hoedown_buffer *tmp = newbuf(doc, BUFFER_BLOCK); - parse_inline(tmp, doc, work.data, work.size); - if (doc->md.paragraph) - doc->md.paragraph(ob, tmp, &doc->data); - popbuf(doc, BUFFER_BLOCK); - } else { - hoedown_buffer *header_work; - - if (work.size) { - size_t beg; - i = work.size; - work.size -= 1; - - while (work.size && data[work.size] != '\n') - work.size -= 1; - - beg = work.size + 1; - while (work.size && data[work.size - 1] == '\n') - work.size -= 1; - - if (work.size > 0) { - hoedown_buffer *tmp = newbuf(doc, BUFFER_BLOCK); - parse_inline(tmp, doc, work.data, work.size); - - if (doc->md.paragraph) - doc->md.paragraph(ob, tmp, &doc->data); - - popbuf(doc, BUFFER_BLOCK); - work.data += beg; - work.size = i - beg; - } - else work.size = i; - } - - header_work = newbuf(doc, BUFFER_SPAN); - parse_inline(header_work, doc, work.data, work.size); - - if (doc->md.header) - doc->md.header(ob, header_work, (int)level, &doc->data); - - popbuf(doc, BUFFER_SPAN); - } - - return end; -} - -/* parse_fencedcode • handles parsing of a block-level code fragment */ -static size_t -parse_fencedcode(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size) -{ - hoedown_buffer text = { 0, 0, 0, 0, NULL, NULL, NULL }; - hoedown_buffer lang = { 0, 0, 0, 0, NULL, NULL, NULL }; - size_t i = 0, text_start, line_start; - size_t w, w2; - size_t width, width2; - uint8_t chr, chr2; - - /* parse codefence line */ - while (i < size && data[i] != '\n') - i++; - - w = parse_codefence(data, i, &lang, &width, &chr); - if (!w) - return 0; - - /* search for end */ - i++; - text_start = i; - while ((line_start = i) < size) { - while (i < size && data[i] != '\n') - i++; - - w2 = is_codefence(data + line_start, i - line_start, &width2, &chr2); - if (w == w2 && width == width2 && chr == chr2 && - is_empty(data + (line_start+w), i - (line_start+w))) - break; - - i++; - } - - text.data = data + text_start; - text.size = line_start - text_start; - - if (doc->md.blockcode) - doc->md.blockcode(ob, text.size ? &text : NULL, lang.size ? &lang : NULL, &doc->data); - - return i; -} - -static size_t -parse_blockcode(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size) -{ - size_t beg, end, pre; - hoedown_buffer *work = 0; - - work = newbuf(doc, BUFFER_BLOCK); - - beg = 0; - while (beg < size) { - for (end = beg + 1; end < size && data[end - 1] != '\n'; end++) {}; - pre = prefix_code(data + beg, end - beg); - - if (pre) - beg += pre; /* skipping prefix */ - else if (!is_empty(data + beg, end - beg)) - /* non-empty non-prefixed line breaks the pre */ - break; - - if (beg < end) { - /* verbatim copy to the working buffer, - escaping entities */ - if (is_empty(data + beg, end - beg)) - hoedown_buffer_putc(work, '\n'); - else hoedown_buffer_put(work, data + beg, end - beg); - } - beg = end; - } - - while (work->size && work->data[work->size - 1] == '\n') - work->size -= 1; - - hoedown_buffer_putc(work, '\n'); - - if (doc->md.blockcode) - doc->md.blockcode(ob, work, NULL, &doc->data); - - popbuf(doc, BUFFER_BLOCK); - return beg; -} - -/* parse_listitem • parsing of a single list item */ -/* assuming initial prefix is already removed */ -static size_t -parse_listitem(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size, hoedown_list_flags *flags) -{ - hoedown_buffer *work = 0, *inter = 0; - size_t beg = 0, end, pre, sublist = 0, orgpre = 0, i; - int in_empty = 0, has_inside_empty = 0, in_fence = 0; - - /* keeping track of the first indentation prefix */ - while (orgpre < 3 && orgpre < size && data[orgpre] == ' ') - orgpre++; - - beg = prefix_uli(data, size); - if (!beg) - beg = prefix_oli(data, size); - - if (!beg) - return 0; - - /* skipping to the beginning of the following line */ - end = beg; - while (end < size && data[end - 1] != '\n') - end++; - - /* getting working buffers */ - work = newbuf(doc, BUFFER_SPAN); - inter = newbuf(doc, BUFFER_SPAN); - - /* putting the first line into the working buffer */ - hoedown_buffer_put(work, data + beg, end - beg); - beg = end; - - /* process the following lines */ - while (beg < size) { - size_t has_next_uli = 0, has_next_oli = 0; - - end++; - - while (end < size && data[end - 1] != '\n') - end++; - - /* process an empty line */ - if (is_empty(data + beg, end - beg)) { - in_empty = 1; - beg = end; - continue; - } - - /* calculating the indentation */ - i = 0; - while (i < 4 && beg + i < end && data[beg + i] == ' ') - i++; - - pre = i; - - if (doc->ext_flags & HOEDOWN_EXT_FENCED_CODE) { - if (is_codefence(data + beg + i, end - beg - i, NULL, NULL)) - in_fence = !in_fence; - } - - /* Only check for new list items if we are **not** inside - * a fenced code block */ - if (!in_fence) { - has_next_uli = prefix_uli(data + beg + i, end - beg - i); - has_next_oli = prefix_oli(data + beg + i, end - beg - i); - } - - /* checking for a new item */ - if ((has_next_uli && !is_hrule(data + beg + i, end - beg - i)) || has_next_oli) { - if (in_empty) - has_inside_empty = 1; - - /* the following item must have the same (or less) indentation */ - if (pre <= orgpre) { - /* if the following item has different list type, we end this list */ - if (in_empty && ( - ((*flags & HOEDOWN_LIST_ORDERED) && has_next_uli) || - (!(*flags & HOEDOWN_LIST_ORDERED) && has_next_oli))) - *flags |= HOEDOWN_LI_END; - - break; - } - - if (!sublist) - sublist = work->size; - } - /* joining only indented stuff after empty lines; - * note that now we only require 1 space of indentation - * to continue a list */ - else if (in_empty && pre == 0) { - *flags |= HOEDOWN_LI_END; - break; - } - - if (in_empty) { - hoedown_buffer_putc(work, '\n'); - has_inside_empty = 1; - in_empty = 0; - } - - /* adding the line without prefix into the working buffer */ - hoedown_buffer_put(work, data + beg + i, end - beg - i); - beg = end; - } - - /* render of li contents */ - if (has_inside_empty) - *flags |= HOEDOWN_LI_BLOCK; - - if (*flags & HOEDOWN_LI_BLOCK) { - /* intermediate render of block li */ - if (sublist && sublist < work->size) { - parse_block(inter, doc, work->data, sublist); - parse_block(inter, doc, work->data + sublist, work->size - sublist); - } - else - parse_block(inter, doc, work->data, work->size); - } else { - /* intermediate render of inline li */ - if (sublist && sublist < work->size) { - parse_inline(inter, doc, work->data, sublist); - parse_block(inter, doc, work->data + sublist, work->size - sublist); - } - else - parse_inline(inter, doc, work->data, work->size); - } - - /* render of li itself */ - if (doc->md.listitem) - doc->md.listitem(ob, inter, *flags, &doc->data); - - popbuf(doc, BUFFER_SPAN); - popbuf(doc, BUFFER_SPAN); - return beg; -} - - -/* parse_list • parsing ordered or unordered list block */ -static size_t -parse_list(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size, hoedown_list_flags flags) -{ - hoedown_buffer *work = 0; - size_t i = 0, j; - - work = newbuf(doc, BUFFER_BLOCK); - - while (i < size) { - j = parse_listitem(work, doc, data + i, size - i, &flags); - i += j; - - if (!j || (flags & HOEDOWN_LI_END)) - break; - } - - if (doc->md.list) - doc->md.list(ob, work, flags, &doc->data); - popbuf(doc, BUFFER_BLOCK); - return i; -} - -/* parse_atxheader • parsing of atx-style headers */ -static size_t -parse_atxheader(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size) -{ - size_t level = 0; - size_t i, end, skip; - - while (level < size && level < 6 && data[level] == '#') - level++; - - for (i = level; i < size && data[i] == ' '; i++); - - for (end = i; end < size && data[end] != '\n'; end++); - skip = end; - - while (end && data[end - 1] == '#') - end--; - - while (end && data[end - 1] == ' ') - end--; - - if (end > i) { - hoedown_buffer *work = newbuf(doc, BUFFER_SPAN); - - parse_inline(work, doc, data + i, end - i); - - if (doc->md.header) - doc->md.header(ob, work, (int)level, &doc->data); - - popbuf(doc, BUFFER_SPAN); - } - - return skip; -} - -/* parse_footnote_def • parse a single footnote definition */ -static void -parse_footnote_def(hoedown_buffer *ob, hoedown_document *doc, unsigned int num, uint8_t *data, size_t size) -{ - hoedown_buffer *work = 0; - work = newbuf(doc, BUFFER_SPAN); - - parse_block(work, doc, data, size); - - if (doc->md.footnote_def) - doc->md.footnote_def(ob, work, num, &doc->data); - popbuf(doc, BUFFER_SPAN); -} - -/* parse_footnote_list • render the contents of the footnotes */ -static void -parse_footnote_list(hoedown_buffer *ob, hoedown_document *doc, struct footnote_list *footnotes) -{ - hoedown_buffer *work = 0; - struct footnote_item *item; - struct footnote_ref *ref; - - if (footnotes->count == 0) - return; - - work = newbuf(doc, BUFFER_BLOCK); - - item = footnotes->head; - while (item) { - ref = item->ref; - parse_footnote_def(work, doc, ref->num, ref->contents->data, ref->contents->size); - item = item->next; - } - - if (doc->md.footnotes) - doc->md.footnotes(ob, work, &doc->data); - popbuf(doc, BUFFER_BLOCK); -} - -/* htmlblock_is_end • check for end of HTML block : ( *)\n */ -/* returns tag length on match, 0 otherwise */ -/* assumes data starts with "<" */ -static size_t -htmlblock_is_end( - const char *tag, - size_t tag_len, - hoedown_document *doc, - uint8_t *data, - size_t size) -{ - size_t i = tag_len + 3, w; - - /* try to match the end tag */ - /* note: we're not considering tags like "" which are still valid */ - if (i > size || - data[1] != '/' || - strncasecmp((char *)data + 2, tag, tag_len) != 0 || - data[tag_len + 2] != '>') - return 0; - - /* rest of the line must be empty */ - if ((w = is_empty(data + i, size - i)) == 0 && i < size) - return 0; - - return i + w; -} - -/* htmlblock_find_end • try to find HTML block ending tag */ -/* returns the length on match, 0 otherwise */ -static size_t -htmlblock_find_end( - const char *tag, - size_t tag_len, - hoedown_document *doc, - uint8_t *data, - size_t size) -{ - size_t i = 0, w; - - while (1) { - while (i < size && data[i] != '<') i++; - if (i >= size) return 0; - - w = htmlblock_is_end(tag, tag_len, doc, data + i, size - i); - if (w) return i + w; - i++; - } -} - -/* htmlblock_find_end_strict • try to find end of HTML block in strict mode */ -/* (it must be an unindented line, and have a blank line afterwads) */ -/* returns the length on match, 0 otherwise */ -static size_t -htmlblock_find_end_strict( - const char *tag, - size_t tag_len, - hoedown_document *doc, - uint8_t *data, - size_t size) -{ - size_t i = 0, mark; - - while (1) { - mark = i; - while (i < size && data[i] != '\n') i++; - if (i < size) i++; - if (i == mark) return 0; - - if (data[mark] == ' ' && mark > 0) continue; - mark += htmlblock_find_end(tag, tag_len, doc, data + mark, i - mark); - if (mark == i && (is_empty(data + i, size - i) || i >= size)) break; - } - - return i; -} - -/* parse_htmlblock • parsing of inline HTML block */ -static size_t -parse_htmlblock(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size, int do_render) -{ - hoedown_buffer work = { NULL, 0, 0, 0, NULL, NULL, NULL }; - size_t i, j = 0, tag_len, tag_end; - const char *curtag = NULL; - - work.data = data; - - /* identification of the opening tag */ - if (size < 2 || data[0] != '<') - return 0; - - i = 1; - while (i < size && data[i] != '>' && data[i] != ' ') - i++; - - if (i < size) - curtag = hoedown_find_block_tag((char *)data + 1, (int)i - 1); - - /* handling of special cases */ - if (!curtag) { - - /* HTML comment, laxist form */ - if (size > 5 && data[1] == '!' && data[2] == '-' && data[3] == '-') { - i = 5; - - while (i < size && !(data[i - 2] == '-' && data[i - 1] == '-' && data[i] == '>')) - i++; - - i++; - - if (i < size) - j = is_empty(data + i, size - i); - - if (j) { - work.size = i + j; - if (do_render && doc->md.blockhtml) - doc->md.blockhtml(ob, &work, &doc->data); - return work.size; - } - } - - /* HR, which is the only self-closing block tag considered */ - if (size > 4 && (data[1] == 'h' || data[1] == 'H') && (data[2] == 'r' || data[2] == 'R')) { - i = 3; - while (i < size && data[i] != '>') - i++; - - if (i + 1 < size) { - i++; - j = is_empty(data + i, size - i); - if (j) { - work.size = i + j; - if (do_render && doc->md.blockhtml) - doc->md.blockhtml(ob, &work, &doc->data); - return work.size; - } - } - } - - /* no special case recognised */ - return 0; - } - - /* looking for a matching closing tag in strict mode */ - tag_len = strlen(curtag); - tag_end = htmlblock_find_end_strict(curtag, tag_len, doc, data, size); - - /* if not found, trying a second pass looking for indented match */ - /* but not if tag is "ins" or "del" (following original Markdown.pl) */ - if (!tag_end && strcmp(curtag, "ins") != 0 && strcmp(curtag, "del") != 0) - tag_end = htmlblock_find_end(curtag, tag_len, doc, data, size); - - if (!tag_end) - return 0; - - /* the end of the block has been found */ - work.size = tag_end; - if (do_render && doc->md.blockhtml) - doc->md.blockhtml(ob, &work, &doc->data); - - return tag_end; -} - -static void -parse_table_row( - hoedown_buffer *ob, - hoedown_document *doc, - uint8_t *data, - size_t size, - size_t columns, - hoedown_table_flags *col_data, - hoedown_table_flags header_flag) -{ - size_t i = 0, col, len; - hoedown_buffer *row_work = 0; - - if (!doc->md.table_cell || !doc->md.table_row) - return; - - row_work = newbuf(doc, BUFFER_SPAN); - - if (i < size && data[i] == '|') - i++; - - for (col = 0; col < columns && i < size; ++col) { - size_t cell_start, cell_end; - hoedown_buffer *cell_work; - - cell_work = newbuf(doc, BUFFER_SPAN); - - while (i < size && _isspace(data[i])) - i++; - - cell_start = i; - - len = find_emph_char(data + i, size - i, '|'); - - /* Two possibilities for len == 0: - 1) No more pipe char found in the current line. - 2) The next pipe is right after the current one, i.e. empty cell. - For case 1, we skip to the end of line; for case 2 we just continue. - */ - if (len == 0 && i < size && data[i] != '|') - len = size - i; - i += len; - - cell_end = i - 1; - - while (cell_end > cell_start && _isspace(data[cell_end])) - cell_end--; - - parse_inline(cell_work, doc, data + cell_start, 1 + cell_end - cell_start); - doc->md.table_cell(row_work, cell_work, col_data[col] | header_flag, &doc->data); - - popbuf(doc, BUFFER_SPAN); - i++; - } - - for (; col < columns; ++col) { - hoedown_buffer empty_cell = { 0, 0, 0, 0, NULL, NULL, NULL }; - doc->md.table_cell(row_work, &empty_cell, col_data[col] | header_flag, &doc->data); - } - - doc->md.table_row(ob, row_work, &doc->data); - - popbuf(doc, BUFFER_SPAN); -} - -static size_t -parse_table_header( - hoedown_buffer *ob, - hoedown_document *doc, - uint8_t *data, - size_t size, - size_t *columns, - hoedown_table_flags **column_data) -{ - int pipes; - size_t i = 0, col, header_end, under_end; - - pipes = 0; - while (i < size && data[i] != '\n') - if (data[i++] == '|') - pipes++; - - if (i == size || pipes == 0) - return 0; - - header_end = i; - - while (header_end > 0 && _isspace(data[header_end - 1])) - header_end--; - - if (data[0] == '|') - pipes--; - - if (header_end && data[header_end - 1] == '|') - pipes--; - - if (pipes < 0) - return 0; - - *columns = pipes + 1; - *column_data = hoedown_calloc(*columns, sizeof(hoedown_table_flags)); - - /* Parse the header underline */ - i++; - if (i < size && data[i] == '|') - i++; - - under_end = i; - while (under_end < size && data[under_end] != '\n') - under_end++; - - for (col = 0; col < *columns && i < under_end; ++col) { - size_t dashes = 0; - - while (i < under_end && data[i] == ' ') - i++; - - if (data[i] == ':') { - i++; (*column_data)[col] |= HOEDOWN_TABLE_ALIGN_LEFT; - dashes++; - } - - while (i < under_end && data[i] == '-') { - i++; dashes++; - } - - if (i < under_end && data[i] == ':') { - i++; (*column_data)[col] |= HOEDOWN_TABLE_ALIGN_RIGHT; - dashes++; - } - - while (i < under_end && data[i] == ' ') - i++; - - if (i < under_end && data[i] != '|' && data[i] != '+') - break; - - if (dashes < 3) - break; - - i++; - } - - if (col < *columns) - return 0; - - parse_table_row( - ob, doc, data, - header_end, - *columns, - *column_data, - HOEDOWN_TABLE_HEADER - ); - - return under_end + 1; -} - -static size_t -parse_table( - hoedown_buffer *ob, - hoedown_document *doc, - uint8_t *data, - size_t size) -{ - size_t i; - - hoedown_buffer *work = 0; - hoedown_buffer *header_work = 0; - hoedown_buffer *body_work = 0; - - size_t columns; - hoedown_table_flags *col_data = NULL; - - work = newbuf(doc, BUFFER_BLOCK); - header_work = newbuf(doc, BUFFER_SPAN); - body_work = newbuf(doc, BUFFER_BLOCK); - - i = parse_table_header(header_work, doc, data, size, &columns, &col_data); - if (i > 0) { - - while (i < size) { - size_t row_start; - int pipes = 0; - - row_start = i; - - while (i < size && data[i] != '\n') - if (data[i++] == '|') - pipes++; - - if (pipes == 0 || i == size) { - i = row_start; - break; - } - - parse_table_row( - body_work, - doc, - data + row_start, - i - row_start, - columns, - col_data, 0 - ); - - i++; - } - - if (doc->md.table_header) - doc->md.table_header(work, header_work, &doc->data); - - if (doc->md.table_body) - doc->md.table_body(work, body_work, &doc->data); - - if (doc->md.table) - doc->md.table(ob, work, &doc->data); - } - - free(col_data); - popbuf(doc, BUFFER_SPAN); - popbuf(doc, BUFFER_BLOCK); - popbuf(doc, BUFFER_BLOCK); - return i; -} - -/* parse_block • parsing of one block, returning next uint8_t to parse */ -static void -parse_block(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size) -{ - size_t beg, end, i; - uint8_t *txt_data; - beg = 0; - - if (doc->work_bufs[BUFFER_SPAN].size + - doc->work_bufs[BUFFER_BLOCK].size > doc->max_nesting) - return; - - while (beg < size) { - txt_data = data + beg; - end = size - beg; - - if (is_atxheader(doc, txt_data, end)) - beg += parse_atxheader(ob, doc, txt_data, end); - - else if (data[beg] == '<' && doc->md.blockhtml && - (i = parse_htmlblock(ob, doc, txt_data, end, 1)) != 0) - beg += i; - - else if ((i = is_empty(txt_data, end)) != 0) - beg += i; - - else if (is_hrule(txt_data, end)) { - if (doc->md.hrule) - doc->md.hrule(ob, &doc->data); - - while (beg < size && data[beg] != '\n') - beg++; - - beg++; - } - - else if ((doc->ext_flags & HOEDOWN_EXT_FENCED_CODE) != 0 && - (i = parse_fencedcode(ob, doc, txt_data, end)) != 0) - beg += i; - - else if ((doc->ext_flags & HOEDOWN_EXT_TABLES) != 0 && - (i = parse_table(ob, doc, txt_data, end)) != 0) - beg += i; - - else if (prefix_quote(txt_data, end)) - beg += parse_blockquote(ob, doc, txt_data, end); - - else if (!(doc->ext_flags & HOEDOWN_EXT_DISABLE_INDENTED_CODE) && prefix_code(txt_data, end)) - beg += parse_blockcode(ob, doc, txt_data, end); - - else if (prefix_uli(txt_data, end)) - beg += parse_list(ob, doc, txt_data, end, 0); - - else if (prefix_oli(txt_data, end)) - beg += parse_list(ob, doc, txt_data, end, HOEDOWN_LIST_ORDERED); - - else - beg += parse_paragraph(ob, doc, txt_data, end); - } -} - - - -/********************* - * REFERENCE PARSING * - *********************/ - -/* is_footnote • returns whether a line is a footnote definition or not */ -static int -is_footnote(const uint8_t *data, size_t beg, size_t end, size_t *last, struct footnote_list *list) -{ - size_t i = 0; - hoedown_buffer *contents = 0; - size_t ind = 0; - int in_empty = 0; - size_t start = 0; - - size_t id_offset, id_end; - - /* up to 3 optional leading spaces */ - if (beg + 3 >= end) return 0; - if (data[beg] == ' ') { i = 1; - if (data[beg + 1] == ' ') { i = 2; - if (data[beg + 2] == ' ') { i = 3; - if (data[beg + 3] == ' ') return 0; } } } - i += beg; - - /* id part: caret followed by anything between brackets */ - if (data[i] != '[') return 0; - i++; - if (i >= end || data[i] != '^') return 0; - i++; - id_offset = i; - while (i < end && data[i] != '\n' && data[i] != '\r' && data[i] != ']') - i++; - if (i >= end || data[i] != ']') return 0; - id_end = i; - - /* spacer: colon (space | tab)* newline? (space | tab)* */ - i++; - if (i >= end || data[i] != ':') return 0; - i++; - - /* getting content buffer */ - contents = hoedown_buffer_new(64); - - start = i; - - /* process lines similar to a list item */ - while (i < end) { - while (i < end && data[i] != '\n' && data[i] != '\r') i++; - - /* process an empty line */ - if (is_empty(data + start, i - start)) { - in_empty = 1; - if (i < end && (data[i] == '\n' || data[i] == '\r')) { - i++; - if (i < end && data[i] == '\n' && data[i - 1] == '\r') i++; - } - start = i; - continue; - } - - /* calculating the indentation */ - ind = 0; - while (ind < 4 && start + ind < end && data[start + ind] == ' ') - ind++; - - /* joining only indented stuff after empty lines; - * note that now we only require 1 space of indentation - * to continue, just like lists */ - if (ind == 0) { - if (start == id_end + 2 && data[start] == '\t') {} - else break; - } - else if (in_empty) { - hoedown_buffer_putc(contents, '\n'); - } - - in_empty = 0; - - /* adding the line into the content buffer */ - hoedown_buffer_put(contents, data + start + ind, i - start - ind); - /* add carriage return */ - if (i < end) { - hoedown_buffer_putc(contents, '\n'); - if (i < end && (data[i] == '\n' || data[i] == '\r')) { - i++; - if (i < end && data[i] == '\n' && data[i - 1] == '\r') i++; - } - } - start = i; - } - - if (last) - *last = start; - - if (list) { - struct footnote_ref *ref; - ref = create_footnote_ref(list, data + id_offset, id_end - id_offset); - if (!ref) - return 0; - if (!add_footnote_ref(list, ref)) { - free_footnote_ref(ref); - return 0; - } - ref->contents = contents; - } - - return 1; -} - -/* is_ref • returns whether a line is a reference or not */ -static int -is_ref(const uint8_t *data, size_t beg, size_t end, size_t *last, struct link_ref **refs) -{ -/* int n; */ - size_t i = 0; - size_t id_offset, id_end; - size_t link_offset, link_end; - size_t title_offset, title_end; - size_t line_end; - - /* up to 3 optional leading spaces */ - if (beg + 3 >= end) return 0; - if (data[beg] == ' ') { i = 1; - if (data[beg + 1] == ' ') { i = 2; - if (data[beg + 2] == ' ') { i = 3; - if (data[beg + 3] == ' ') return 0; } } } - i += beg; - - /* id part: anything but a newline between brackets */ - if (data[i] != '[') return 0; - i++; - id_offset = i; - while (i < end && data[i] != '\n' && data[i] != '\r' && data[i] != ']') - i++; - if (i >= end || data[i] != ']') return 0; - id_end = i; - - /* spacer: colon (space | tab)* newline? (space | tab)* */ - i++; - if (i >= end || data[i] != ':') return 0; - i++; - while (i < end && data[i] == ' ') i++; - if (i < end && (data[i] == '\n' || data[i] == '\r')) { - i++; - if (i < end && data[i] == '\r' && data[i - 1] == '\n') i++; } - while (i < end && data[i] == ' ') i++; - if (i >= end) return 0; - - /* link: spacing-free sequence, optionally between angle brackets */ - if (data[i] == '<') - i++; - - link_offset = i; - - while (i < end && data[i] != ' ' && data[i] != '\n' && data[i] != '\r') - i++; - - if (data[i - 1] == '>') link_end = i - 1; - else link_end = i; - - /* optional spacer: (space | tab)* (newline | '\'' | '"' | '(' ) */ - while (i < end && data[i] == ' ') i++; - if (i < end && data[i] != '\n' && data[i] != '\r' - && data[i] != '\'' && data[i] != '"' && data[i] != '(') - return 0; - line_end = 0; - /* computing end-of-line */ - if (i >= end || data[i] == '\r' || data[i] == '\n') line_end = i; - if (i + 1 < end && data[i] == '\n' && data[i + 1] == '\r') - line_end = i + 1; - - /* optional (space|tab)* spacer after a newline */ - if (line_end) { - i = line_end + 1; - while (i < end && data[i] == ' ') i++; } - - /* optional title: any non-newline sequence enclosed in '"() - alone on its line */ - title_offset = title_end = 0; - if (i + 1 < end - && (data[i] == '\'' || data[i] == '"' || data[i] == '(')) { - i++; - title_offset = i; - /* looking for EOL */ - while (i < end && data[i] != '\n' && data[i] != '\r') i++; - if (i + 1 < end && data[i] == '\n' && data[i + 1] == '\r') - title_end = i + 1; - else title_end = i; - /* stepping back */ - i -= 1; - while (i > title_offset && data[i] == ' ') - i -= 1; - if (i > title_offset - && (data[i] == '\'' || data[i] == '"' || data[i] == ')')) { - line_end = title_end; - title_end = i; } } - - if (!line_end || link_end == link_offset) - return 0; /* garbage after the link empty link */ - - /* a valid ref has been found, filling-in return structures */ - if (last) - *last = line_end; - - if (refs) { - struct link_ref *ref; - - ref = add_link_ref(refs, data + id_offset, id_end - id_offset); - if (!ref) - return 0; - - ref->link = hoedown_buffer_new(link_end - link_offset); - hoedown_buffer_put(ref->link, data + link_offset, link_end - link_offset); - - if (title_end > title_offset) { - ref->title = hoedown_buffer_new(title_end - title_offset); - hoedown_buffer_put(ref->title, data + title_offset, title_end - title_offset); - } - } - - return 1; -} - -static void expand_tabs(hoedown_buffer *ob, const uint8_t *line, size_t size) -{ - /* This code makes two assumptions: - * - Input is valid UTF-8. (Any byte with top two bits 10 is skipped, - * whether or not it is a valid UTF-8 continuation byte.) - * - Input contains no combining characters. (Combining characters - * should be skipped but are not.) - */ - size_t i = 0, tab = 0; - - while (i < size) { - size_t org = i; - - while (i < size && line[i] != '\t') { - /* ignore UTF-8 continuation bytes */ - if ((line[i] & 0xc0) != 0x80) - tab++; - i++; - } - - if (i > org) - hoedown_buffer_put(ob, line + org, i - org); - - if (i >= size) - break; - - do { - hoedown_buffer_putc(ob, ' '); tab++; - } while (tab % 4); - - i++; - } -} - -/********************** - * EXPORTED FUNCTIONS * - **********************/ - -hoedown_document * -hoedown_document_new( - const hoedown_renderer *renderer, - hoedown_extensions extensions, - size_t max_nesting) -{ - hoedown_document *doc = NULL; - - assert(max_nesting > 0 && renderer); - - doc = hoedown_malloc(sizeof(hoedown_document)); - memcpy(&doc->md, renderer, sizeof(hoedown_renderer)); - - doc->data.opaque = renderer->opaque; - - hoedown_stack_init(&doc->work_bufs[BUFFER_BLOCK], 4); - hoedown_stack_init(&doc->work_bufs[BUFFER_SPAN], 8); - - memset(doc->active_char, 0x0, 256); - - if (extensions & HOEDOWN_EXT_UNDERLINE && doc->md.underline) { - doc->active_char['_'] = MD_CHAR_EMPHASIS; - } - - if (doc->md.emphasis || doc->md.double_emphasis || doc->md.triple_emphasis) { - doc->active_char['*'] = MD_CHAR_EMPHASIS; - doc->active_char['_'] = MD_CHAR_EMPHASIS; - if (extensions & HOEDOWN_EXT_STRIKETHROUGH) - doc->active_char['~'] = MD_CHAR_EMPHASIS; - if (extensions & HOEDOWN_EXT_HIGHLIGHT) - doc->active_char['='] = MD_CHAR_EMPHASIS; - } - - if (doc->md.codespan) - doc->active_char['`'] = MD_CHAR_CODESPAN; - - if (doc->md.linebreak) - doc->active_char['\n'] = MD_CHAR_LINEBREAK; - - if (doc->md.image || doc->md.link || doc->md.footnotes || doc->md.footnote_ref) - doc->active_char['['] = MD_CHAR_LINK; - - doc->active_char['<'] = MD_CHAR_LANGLE; - doc->active_char['\\'] = MD_CHAR_ESCAPE; - doc->active_char['&'] = MD_CHAR_ENTITY; - - if (extensions & HOEDOWN_EXT_AUTOLINK) { - doc->active_char[':'] = MD_CHAR_AUTOLINK_URL; - doc->active_char['@'] = MD_CHAR_AUTOLINK_EMAIL; - doc->active_char['w'] = MD_CHAR_AUTOLINK_WWW; - } - - if (extensions & HOEDOWN_EXT_SUPERSCRIPT) - doc->active_char['^'] = MD_CHAR_SUPERSCRIPT; - - if (extensions & HOEDOWN_EXT_QUOTE) - doc->active_char['"'] = MD_CHAR_QUOTE; - - if (extensions & HOEDOWN_EXT_MATH) - doc->active_char['$'] = MD_CHAR_MATH; - - /* Extension data */ - doc->ext_flags = extensions; - doc->max_nesting = max_nesting; - doc->in_link_body = 0; - - return doc; -} - -void -hoedown_document_render(hoedown_document *doc, hoedown_buffer *ob, const uint8_t *data, size_t size) -{ - static const uint8_t UTF8_BOM[] = {0xEF, 0xBB, 0xBF}; - - hoedown_buffer *text; - size_t beg, end; - - int footnotes_enabled; - - text = hoedown_buffer_new(64); - - /* Preallocate enough space for our buffer to avoid expanding while copying */ - hoedown_buffer_grow(text, size); - - /* reset the references table */ - memset(&doc->refs, 0x0, REF_TABLE_SIZE * sizeof(void *)); - - footnotes_enabled = doc->ext_flags & HOEDOWN_EXT_FOOTNOTES; - - /* reset the footnotes lists */ - if (footnotes_enabled) { - memset(&doc->footnotes_found, 0x0, sizeof(doc->footnotes_found)); - memset(&doc->footnotes_used, 0x0, sizeof(doc->footnotes_used)); - } - - /* first pass: looking for references, copying everything else */ - beg = 0; - - /* Skip a possible UTF-8 BOM, even though the Unicode standard - * discourages having these in UTF-8 documents */ - if (size >= 3 && memcmp(data, UTF8_BOM, 3) == 0) - beg += 3; - - while (beg < size) /* iterating over lines */ - if (footnotes_enabled && is_footnote(data, beg, size, &end, &doc->footnotes_found)) - beg = end; - else if (is_ref(data, beg, size, &end, doc->refs)) - beg = end; - else { /* skipping to the next line */ - end = beg; - while (end < size && data[end] != '\n' && data[end] != '\r') - end++; - - /* adding the line body if present */ - if (end > beg) - expand_tabs(text, data + beg, end - beg); - - while (end < size && (data[end] == '\n' || data[end] == '\r')) { - /* add one \n per newline */ - if (data[end] == '\n' || (end + 1 < size && data[end + 1] != '\n')) - hoedown_buffer_putc(text, '\n'); - end++; - } - - beg = end; - } - - /* pre-grow the output buffer to minimize allocations */ - hoedown_buffer_grow(ob, text->size + (text->size >> 1)); - - /* second pass: actual rendering */ - if (doc->md.doc_header) - doc->md.doc_header(ob, 0, &doc->data); - - if (text->size) { - /* adding a final newline if not already present */ - if (text->data[text->size - 1] != '\n' && text->data[text->size - 1] != '\r') - hoedown_buffer_putc(text, '\n'); - - parse_block(ob, doc, text->data, text->size); - } - - /* footnotes */ - if (footnotes_enabled) - parse_footnote_list(ob, doc, &doc->footnotes_used); - - if (doc->md.doc_footer) - doc->md.doc_footer(ob, 0, &doc->data); - - /* clean-up */ - hoedown_buffer_free(text); - free_link_refs(doc->refs); - if (footnotes_enabled) { - free_footnote_list(&doc->footnotes_found, 1); - free_footnote_list(&doc->footnotes_used, 0); - } - - assert(doc->work_bufs[BUFFER_SPAN].size == 0); - assert(doc->work_bufs[BUFFER_BLOCK].size == 0); -} - -void -hoedown_document_render_inline(hoedown_document *doc, hoedown_buffer *ob, const uint8_t *data, size_t size) -{ - size_t i = 0, mark; - hoedown_buffer *text = hoedown_buffer_new(64); - - /* reset the references table */ - memset(&doc->refs, 0x0, REF_TABLE_SIZE * sizeof(void *)); - - /* first pass: expand tabs and process newlines */ - hoedown_buffer_grow(text, size); - while (1) { - mark = i; - while (i < size && data[i] != '\n' && data[i] != '\r') - i++; - - expand_tabs(text, data + mark, i - mark); - - if (i >= size) - break; - - while (i < size && (data[i] == '\n' || data[i] == '\r')) { - /* add one \n per newline */ - if (data[i] == '\n' || (i + 1 < size && data[i + 1] != '\n')) - hoedown_buffer_putc(text, '\n'); - i++; - } - } - - /* second pass: actual rendering */ - hoedown_buffer_grow(ob, text->size + (text->size >> 1)); - - if (doc->md.doc_header) - doc->md.doc_header(ob, 1, &doc->data); - - parse_inline(ob, doc, text->data, text->size); - - if (doc->md.doc_footer) - doc->md.doc_footer(ob, 1, &doc->data); - - /* clean-up */ - hoedown_buffer_free(text); - - assert(doc->work_bufs[BUFFER_SPAN].size == 0); - assert(doc->work_bufs[BUFFER_BLOCK].size == 0); -} - -void -hoedown_document_free(hoedown_document *doc) -{ - size_t i; - - for (i = 0; i < (size_t)doc->work_bufs[BUFFER_SPAN].asize; ++i) - hoedown_buffer_free(doc->work_bufs[BUFFER_SPAN].item[i]); - - for (i = 0; i < (size_t)doc->work_bufs[BUFFER_BLOCK].asize; ++i) - hoedown_buffer_free(doc->work_bufs[BUFFER_BLOCK].item[i]); - - hoedown_stack_uninit(&doc->work_bufs[BUFFER_SPAN]); - hoedown_stack_uninit(&doc->work_bufs[BUFFER_BLOCK]); - - free(doc); -} diff --git a/Sources/CHoedown/escape.c b/Sources/CHoedown/escape.c deleted file mode 100644 index 122c6ec..0000000 --- a/Sources/CHoedown/escape.c +++ /dev/null @@ -1,188 +0,0 @@ -#include "escape.h" - -#include -#include -#include - - -#define likely(x) __builtin_expect((x),1) -#define unlikely(x) __builtin_expect((x),0) - - -/* - * The following characters will not be escaped: - * - * -_.+!*'(),%#@?=;:/,+&$ alphanum - * - * Note that this character set is the addition of: - * - * - The characters which are safe to be in an URL - * - The characters which are *not* safe to be in - * an URL because they are RESERVED characters. - * - * We assume (lazily) that any RESERVED char that - * appears inside an URL is actually meant to - * have its native function (i.e. as an URL - * component/separator) and hence needs no escaping. - * - * There are two exceptions: the chacters & (amp) - * and ' (single quote) do not appear in the table. - * They are meant to appear in the URL as components, - * yet they require special HTML-entity escaping - * to generate valid HTML markup. - * - * All other characters will be escaped to %XX. - * - */ -static const uint8_t HREF_SAFE[UINT8_MAX+1] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -void -hoedown_escape_href(hoedown_buffer *ob, const uint8_t *data, size_t size) -{ - static const char hex_chars[] = "0123456789ABCDEF"; - size_t i = 0, mark; - char hex_str[3]; - - hex_str[0] = '%'; - - while (i < size) { - mark = i; - while (i < size && HREF_SAFE[data[i]]) i++; - - /* Optimization for cases where there's nothing to escape */ - if (mark == 0 && i >= size) { - hoedown_buffer_put(ob, data, size); - return; - } - - if (likely(i > mark)) { - hoedown_buffer_put(ob, data + mark, i - mark); - } - - /* escaping */ - if (i >= size) - break; - - switch (data[i]) { - /* amp appears all the time in URLs, but needs - * HTML-entity escaping to be inside an href */ - case '&': - HOEDOWN_BUFPUTSL(ob, "&"); - break; - - /* the single quote is a valid URL character - * according to the standard; it needs HTML - * entity escaping too */ - case '\'': - HOEDOWN_BUFPUTSL(ob, "'"); - break; - - /* the space can be escaped to %20 or a plus - * sign. we're going with the generic escape - * for now. the plus thing is more commonly seen - * when building GET strings */ -#if 0 - case ' ': - hoedown_buffer_putc(ob, '+'); - break; -#endif - - /* every other character goes with a %XX escaping */ - default: - hex_str[1] = hex_chars[(data[i] >> 4) & 0xF]; - hex_str[2] = hex_chars[data[i] & 0xF]; - hoedown_buffer_put(ob, (uint8_t *)hex_str, 3); - } - - i++; - } -} - - -/** - * According to the OWASP rules: - * - * & --> & - * < --> < - * > --> > - * " --> " - * ' --> ' ' is not recommended - * / --> / forward slash is included as it helps end an HTML entity - * - */ -static const uint8_t HTML_ESCAPE_TABLE[UINT8_MAX+1] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 6, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static const char *HTML_ESCAPES[] = { - "", - """, - "&", - "'", - "/", - "<", - ">" -}; - -void -hoedown_escape_html(hoedown_buffer *ob, const uint8_t *data, size_t size, int secure) -{ - size_t i = 0, mark; - - while (1) { - mark = i; - while (i < size && HTML_ESCAPE_TABLE[data[i]] == 0) i++; - - /* Optimization for cases where there's nothing to escape */ - if (mark == 0 && i >= size) { - hoedown_buffer_put(ob, data, size); - return; - } - - if (likely(i > mark)) - hoedown_buffer_put(ob, data + mark, i - mark); - - if (i >= size) break; - - /* The forward slash is only escaped in secure mode */ - if (!secure && data[i] == '/') { - hoedown_buffer_putc(ob, '/'); - } else { - hoedown_buffer_puts(ob, HTML_ESCAPES[HTML_ESCAPE_TABLE[data[i]]]); - } - - i++; - } -} diff --git a/Sources/CHoedown/hoedown_html_patch.c b/Sources/CHoedown/hoedown_html_patch.c deleted file mode 100644 index 4a9563f..0000000 --- a/Sources/CHoedown/hoedown_html_patch.c +++ /dev/null @@ -1,185 +0,0 @@ -// -// hoedown_html_patch.c -// MacDown -// -// Created by Tzu-ping Chung on 14/06/2014. -// Copyright (c) 2014 Tzu-ping Chung . All rights reserved. -// - -#include -#include "escape.h" -#include "document.h" -#include "html.h" -#include "hoedown_html_patch.h" - -#define USE_XHTML(opt) (opt->flags & HOEDOWN_HTML_USE_XHTML) -#define USE_BLOCKCODE_INFORMATION(opt) \ - (opt->flags & HOEDOWN_HTML_BLOCKCODE_INFORMATION) -#define USE_TASK_LIST(opt) (opt->flags & HOEDOWN_HTML_USE_TASK_LIST) - -// rndr_blockcode from HEAD. The "language-" prefix in class in needed to make -// the HTML compatible with Prism. -void hoedown_patch_render_blockcode( - hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_buffer *lang, - const hoedown_renderer_data *data) -{ - if (ob->size) hoedown_buffer_putc(ob, '\n'); - - hoedown_html_renderer_state *state = data->opaque; - hoedown_html_renderer_state_extra *extra = state->opaque; - - hoedown_buffer *front = NULL; - hoedown_buffer *back = NULL; - if (lang && USE_BLOCKCODE_INFORMATION(state)) - { - front = hoedown_buffer_new(lang->size); - back = hoedown_buffer_new(lang->size); - - hoedown_buffer *current = front; - for (size_t i = 0; i < lang->size; i++) - { - uint8_t c = lang->data[i]; - if (current == front && c == ':') - current = back; - else - hoedown_buffer_putc(current, c); - } - lang = front; - } - - hoedown_buffer *mapped = NULL; - if (lang && extra->language_addition) - { - mapped = extra->language_addition(lang, extra->owner); - if (mapped) - lang = mapped; - } - - HOEDOWN_BUFPUTSL(ob, "
flags & HOEDOWN_HTML_BLOCKCODE_LINE_NUMBERS) - HOEDOWN_BUFPUTSL(ob, " class=\"line-numbers\""); - if (back && back->size) - { - HOEDOWN_BUFPUTSL(ob, " data-information=\""); - hoedown_buffer_put(ob, back->data, back->size); - HOEDOWN_BUFPUTSL(ob, "\""); - } - HOEDOWN_BUFPUTSL(ob, ">size) - hoedown_escape_html(ob, lang->data, lang->size, 0); - else - HOEDOWN_BUFPUTSL(ob, "none"); - HOEDOWN_BUFPUTSL(ob, "\">"); - - if (text) - { - // Remove last newline to prevent prism from adding a blank line at the - // end of code blocks. - size_t size = text->size; - if (size > 0 && text->data[size - 1] == '\n') - size--; - hoedown_escape_html(ob, text->data, size, 0); - } - - HOEDOWN_BUFPUTSL(ob, "
\n"); - - hoedown_buffer_free(mapped); - hoedown_buffer_free(front); - hoedown_buffer_free(back); -} - -// Supports task list syntax if HOEDOWN_HTML_USE_TASK_LIST is on. -// Implementation based on hoextdown. -void hoedown_patch_render_listitem( - hoedown_buffer *ob, const hoedown_buffer *text, hoedown_list_flags flags, - const hoedown_renderer_data *data) -{ - if (text) - { - hoedown_html_renderer_state *state = data->opaque; - size_t offset = 0; - if (flags & HOEDOWN_LI_BLOCK) - offset = 3; - - // Do task list checkbox ([x] or [ ]). - if (USE_TASK_LIST(state) && text->size >= 3) - { - if (strncmp((char *)(text->data + offset), "[ ]", 3) == 0) - { - HOEDOWN_BUFPUTSL(ob, "
  • "); - hoedown_buffer_put(ob, text->data, offset); - if (USE_XHTML(state)) - HOEDOWN_BUFPUTSL(ob, ""); - else - HOEDOWN_BUFPUTSL(ob, ""); - offset += 3; - } - else if (strncmp((char *)(text->data + offset), "[x]", 3) == 0) - { - HOEDOWN_BUFPUTSL(ob, "
  • "); - hoedown_buffer_put(ob, text->data, offset); - if (USE_XHTML(state)) - HOEDOWN_BUFPUTSL(ob, ""); - else - HOEDOWN_BUFPUTSL(ob, ""); - offset += 3; - } - else - { - HOEDOWN_BUFPUTSL(ob, "
  • "); - offset = 0; - } - } - else - { - HOEDOWN_BUFPUTSL(ob, "
  • "); - offset = 0; - } - size_t size = text->size; - while (size && text->data[size - offset - 1] == '\n') - size--; - - hoedown_buffer_put(ob, text->data + offset, size - offset); - } - HOEDOWN_BUFPUTSL(ob, "
  • \n"); -} - -// Adds a "toc" class to the outmost UL element to support TOC styling. -void hoedown_patch_render_toc_header( - hoedown_buffer *ob, const hoedown_buffer *content, int level, - const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state = data->opaque; - - if (level <= state->toc_data.nesting_level) { - /* set the level offset if this is the first header - * we're parsing for the document */ - if (state->toc_data.current_level == 0) - state->toc_data.level_offset = level - 1; - - level -= state->toc_data.level_offset; - - if (level > state->toc_data.current_level) { - while (level > state->toc_data.current_level) { - if (state->toc_data.current_level == 0) - HOEDOWN_BUFPUTSL(ob, "
      \n
    • \n"); - else - HOEDOWN_BUFPUTSL(ob, "
        \n
      • \n"); - state->toc_data.current_level++; - } - } else if (level < state->toc_data.current_level) { - HOEDOWN_BUFPUTSL(ob, "
      • \n"); - while (level < state->toc_data.current_level) { - HOEDOWN_BUFPUTSL(ob, "
      \n
    • \n"); - state->toc_data.current_level--; - } - HOEDOWN_BUFPUTSL(ob,"
    • \n"); - } else { - HOEDOWN_BUFPUTSL(ob,"
    • \n
    • \n"); - } - - hoedown_buffer_printf(ob, "", state->toc_data.header_count++); - if (content) hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, "\n"); - } -} diff --git a/Sources/CHoedown/html.c b/Sources/CHoedown/html.c deleted file mode 100644 index b5101c1..0000000 --- a/Sources/CHoedown/html.c +++ /dev/null @@ -1,754 +0,0 @@ -#include "html.h" - -#include -#include -#include -#include - -#include "escape.h" - -#define USE_XHTML(opt) (opt->flags & HOEDOWN_HTML_USE_XHTML) - -hoedown_html_tag -hoedown_html_is_tag(const uint8_t *data, size_t size, const char *tagname) -{ - size_t i; - int closed = 0; - - if (size < 3 || data[0] != '<') - return HOEDOWN_HTML_TAG_NONE; - - i = 1; - - if (data[i] == '/') { - closed = 1; - i++; - } - - for (; i < size; ++i, ++tagname) { - if (*tagname == 0) - break; - - if (data[i] != *tagname) - return HOEDOWN_HTML_TAG_NONE; - } - - if (i == size) - return HOEDOWN_HTML_TAG_NONE; - - if (isspace(data[i]) || data[i] == '>') - return closed ? HOEDOWN_HTML_TAG_CLOSE : HOEDOWN_HTML_TAG_OPEN; - - return HOEDOWN_HTML_TAG_NONE; -} - -static void escape_html(hoedown_buffer *ob, const uint8_t *source, size_t length) -{ - hoedown_escape_html(ob, source, length, 0); -} - -static void escape_href(hoedown_buffer *ob, const uint8_t *source, size_t length) -{ - hoedown_escape_href(ob, source, length); -} - -/******************** - * GENERIC RENDERER * - ********************/ -static int -rndr_autolink(hoedown_buffer *ob, const hoedown_buffer *link, hoedown_autolink_type type, const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state = data->opaque; - - if (!link || !link->size) - return 0; - - HOEDOWN_BUFPUTSL(ob, "data, link->size); - - if (state->link_attributes) { - hoedown_buffer_putc(ob, '\"'); - state->link_attributes(ob, link, data); - hoedown_buffer_putc(ob, '>'); - } else { - HOEDOWN_BUFPUTSL(ob, "\">"); - } - - /* - * Pretty printing: if we get an email address as - * an actual URI, e.g. `mailto:foo@bar.com`, we don't - * want to print the `mailto:` prefix - */ - if (hoedown_buffer_prefix(link, "mailto:") == 0) { - escape_html(ob, link->data + 7, link->size - 7); - } else { - escape_html(ob, link->data, link->size); - } - - HOEDOWN_BUFPUTSL(ob, ""); - - return 1; -} - -static void -rndr_blockcode(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_buffer *lang, const hoedown_renderer_data *data) -{ - if (ob->size) hoedown_buffer_putc(ob, '\n'); - - if (lang) { - HOEDOWN_BUFPUTSL(ob, "
      data, lang->size);
      -		HOEDOWN_BUFPUTSL(ob, "\">");
      -	} else {
      -		HOEDOWN_BUFPUTSL(ob, "
      ");
      -	}
      -
      -	if (text)
      -		escape_html(ob, text->data, text->size);
      -
      -	HOEDOWN_BUFPUTSL(ob, "
      \n"); -} - -static void -rndr_blockquote(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (ob->size) hoedown_buffer_putc(ob, '\n'); - HOEDOWN_BUFPUTSL(ob, "
      \n"); - if (content) hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, "
      \n"); -} - -static int -rndr_codespan(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_renderer_data *data) -{ - HOEDOWN_BUFPUTSL(ob, ""); - if (text) escape_html(ob, text->data, text->size); - HOEDOWN_BUFPUTSL(ob, ""); - return 1; -} - -static int -rndr_strikethrough(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (!content || !content->size) - return 0; - - HOEDOWN_BUFPUTSL(ob, ""); - hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, ""); - return 1; -} - -static int -rndr_double_emphasis(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (!content || !content->size) - return 0; - - HOEDOWN_BUFPUTSL(ob, ""); - hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, ""); - - return 1; -} - -static int -rndr_emphasis(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (!content || !content->size) return 0; - HOEDOWN_BUFPUTSL(ob, ""); - if (content) hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, ""); - return 1; -} - -static int -rndr_underline(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (!content || !content->size) - return 0; - - HOEDOWN_BUFPUTSL(ob, ""); - hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, ""); - - return 1; -} - -static int -rndr_highlight(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (!content || !content->size) - return 0; - - HOEDOWN_BUFPUTSL(ob, ""); - hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, ""); - - return 1; -} - -static int -rndr_quote(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (!content || !content->size) - return 0; - - HOEDOWN_BUFPUTSL(ob, ""); - hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, ""); - - return 1; -} - -static int -rndr_linebreak(hoedown_buffer *ob, const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state = data->opaque; - hoedown_buffer_puts(ob, USE_XHTML(state) ? "
      \n" : "
      \n"); - return 1; -} - -static void -rndr_header(hoedown_buffer *ob, const hoedown_buffer *content, int level, const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state = data->opaque; - - if (ob->size) - hoedown_buffer_putc(ob, '\n'); - - if (level <= state->toc_data.nesting_level) - hoedown_buffer_printf(ob, "", level, state->toc_data.header_count++); - else - hoedown_buffer_printf(ob, "", level); - - if (content) hoedown_buffer_put(ob, content->data, content->size); - hoedown_buffer_printf(ob, "\n", level); -} - -static int -rndr_link(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_buffer *link, const hoedown_buffer *title, const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state = data->opaque; - - HOEDOWN_BUFPUTSL(ob, "size) - escape_href(ob, link->data, link->size); - - if (title && title->size) { - HOEDOWN_BUFPUTSL(ob, "\" title=\""); - escape_html(ob, title->data, title->size); - } - - if (state->link_attributes) { - hoedown_buffer_putc(ob, '\"'); - state->link_attributes(ob, link, data); - hoedown_buffer_putc(ob, '>'); - } else { - HOEDOWN_BUFPUTSL(ob, "\">"); - } - - if (content && content->size) hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, ""); - return 1; -} - -static void -rndr_list(hoedown_buffer *ob, const hoedown_buffer *content, hoedown_list_flags flags, const hoedown_renderer_data *data) -{ - if (ob->size) hoedown_buffer_putc(ob, '\n'); - hoedown_buffer_put(ob, (const uint8_t *)(flags & HOEDOWN_LIST_ORDERED ? "
        \n" : "
          \n"), 5); - if (content) hoedown_buffer_put(ob, content->data, content->size); - hoedown_buffer_put(ob, (const uint8_t *)(flags & HOEDOWN_LIST_ORDERED ? "
      \n" : "
    \n"), 6); -} - -static void -rndr_listitem(hoedown_buffer *ob, const hoedown_buffer *content, hoedown_list_flags flags, const hoedown_renderer_data *data) -{ - HOEDOWN_BUFPUTSL(ob, "
  • "); - if (content) { - size_t size = content->size; - while (size && content->data[size - 1] == '\n') - size--; - - hoedown_buffer_put(ob, content->data, size); - } - HOEDOWN_BUFPUTSL(ob, "
  • \n"); -} - -static void -rndr_paragraph(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state = data->opaque; - size_t i = 0; - - if (ob->size) hoedown_buffer_putc(ob, '\n'); - - if (!content || !content->size) - return; - - while (i < content->size && isspace(content->data[i])) i++; - - if (i == content->size) - return; - - HOEDOWN_BUFPUTSL(ob, "

    "); - if (state->flags & HOEDOWN_HTML_HARD_WRAP) { - size_t org; - while (i < content->size) { - org = i; - while (i < content->size && content->data[i] != '\n') - i++; - - if (i > org) - hoedown_buffer_put(ob, content->data + org, i - org); - - /* - * do not insert a line break if this newline - * is the last character on the paragraph - */ - if (i >= content->size - 1) - break; - - rndr_linebreak(ob, data); - i++; - } - } else { - hoedown_buffer_put(ob, content->data + i, content->size - i); - } - HOEDOWN_BUFPUTSL(ob, "

    \n"); -} - -static void -rndr_raw_block(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_renderer_data *data) -{ - size_t org, sz; - - if (!text) - return; - - /* FIXME: Do we *really* need to trim the HTML? How does that make a difference? */ - sz = text->size; - while (sz > 0 && text->data[sz - 1] == '\n') - sz--; - - org = 0; - while (org < sz && text->data[org] == '\n') - org++; - - if (org >= sz) - return; - - if (ob->size) - hoedown_buffer_putc(ob, '\n'); - - hoedown_buffer_put(ob, text->data + org, sz - org); - hoedown_buffer_putc(ob, '\n'); -} - -static int -rndr_triple_emphasis(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (!content || !content->size) return 0; - HOEDOWN_BUFPUTSL(ob, ""); - hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, ""); - return 1; -} - -static void -rndr_hrule(hoedown_buffer *ob, const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state = data->opaque; - if (ob->size) hoedown_buffer_putc(ob, '\n'); - hoedown_buffer_puts(ob, USE_XHTML(state) ? "
    \n" : "
    \n"); -} - -static int -rndr_image(hoedown_buffer *ob, const hoedown_buffer *link, const hoedown_buffer *title, const hoedown_buffer *alt, const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state = data->opaque; - if (!link || !link->size) return 0; - - HOEDOWN_BUFPUTSL(ob, "data, link->size); - HOEDOWN_BUFPUTSL(ob, "\" alt=\""); - - if (alt && alt->size) - escape_html(ob, alt->data, alt->size); - - if (title && title->size) { - HOEDOWN_BUFPUTSL(ob, "\" title=\""); - escape_html(ob, title->data, title->size); } - - hoedown_buffer_puts(ob, USE_XHTML(state) ? "\"/>" : "\">"); - return 1; -} - -static int -rndr_raw_html(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state = data->opaque; - - /* ESCAPE overrides SKIP_HTML. It doesn't look to see if - * there are any valid tags, just escapes all of them. */ - if((state->flags & HOEDOWN_HTML_ESCAPE) != 0) { - escape_html(ob, text->data, text->size); - return 1; - } - - if ((state->flags & HOEDOWN_HTML_SKIP_HTML) != 0) - return 1; - - hoedown_buffer_put(ob, text->data, text->size); - return 1; -} - -static void -rndr_table(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (ob->size) hoedown_buffer_putc(ob, '\n'); - HOEDOWN_BUFPUTSL(ob, "\n"); - hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, "
    \n"); -} - -static void -rndr_table_header(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (ob->size) hoedown_buffer_putc(ob, '\n'); - HOEDOWN_BUFPUTSL(ob, "\n"); - hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, "\n"); -} - -static void -rndr_table_body(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (ob->size) hoedown_buffer_putc(ob, '\n'); - HOEDOWN_BUFPUTSL(ob, "\n"); - hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, "\n"); -} - -static void -rndr_tablerow(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - HOEDOWN_BUFPUTSL(ob, "\n"); - if (content) hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, "\n"); -} - -static void -rndr_tablecell(hoedown_buffer *ob, const hoedown_buffer *content, hoedown_table_flags flags, const hoedown_renderer_data *data) -{ - if (flags & HOEDOWN_TABLE_HEADER) { - HOEDOWN_BUFPUTSL(ob, ""); - break; - - case HOEDOWN_TABLE_ALIGN_LEFT: - HOEDOWN_BUFPUTSL(ob, " style=\"text-align: left\">"); - break; - - case HOEDOWN_TABLE_ALIGN_RIGHT: - HOEDOWN_BUFPUTSL(ob, " style=\"text-align: right\">"); - break; - - default: - HOEDOWN_BUFPUTSL(ob, ">"); - } - - if (content) - hoedown_buffer_put(ob, content->data, content->size); - - if (flags & HOEDOWN_TABLE_HEADER) { - HOEDOWN_BUFPUTSL(ob, "\n"); - } else { - HOEDOWN_BUFPUTSL(ob, "\n"); - } -} - -static int -rndr_superscript(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (!content || !content->size) return 0; - HOEDOWN_BUFPUTSL(ob, ""); - hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, ""); - return 1; -} - -static void -rndr_normal_text(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - if (content) - escape_html(ob, content->data, content->size); -} - -static void -rndr_footnotes(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state = data->opaque; - - if (ob->size) hoedown_buffer_putc(ob, '\n'); - HOEDOWN_BUFPUTSL(ob, "
    \n"); - hoedown_buffer_puts(ob, USE_XHTML(state) ? "
    \n" : "
    \n"); - HOEDOWN_BUFPUTSL(ob, "
      \n"); - - if (content) hoedown_buffer_put(ob, content->data, content->size); - - HOEDOWN_BUFPUTSL(ob, "\n
    \n
    \n"); -} - -static void -rndr_footnote_def(hoedown_buffer *ob, const hoedown_buffer *content, unsigned int num, const hoedown_renderer_data *data) -{ - size_t i = 0; - int pfound = 0; - - /* insert anchor at the end of first paragraph block */ - if (content) { - while ((i+3) < content->size) { - if (content->data[i++] != '<') continue; - if (content->data[i++] != '/') continue; - if (content->data[i++] != 'p' && content->data[i] != 'P') continue; - if (content->data[i] != '>') continue; - i -= 3; - pfound = 1; - break; - } - } - - hoedown_buffer_printf(ob, "\n
  • \n", num); - if (pfound) { - hoedown_buffer_put(ob, content->data, i); - hoedown_buffer_printf(ob, " ↩", num); - hoedown_buffer_put(ob, content->data + i, content->size - i); - } else if (content) { - hoedown_buffer_put(ob, content->data, content->size); - } - HOEDOWN_BUFPUTSL(ob, "
  • \n"); -} - -static int -rndr_footnote_ref(hoedown_buffer *ob, unsigned int num, const hoedown_renderer_data *data) -{ - hoedown_buffer_printf(ob, "%d", num, num, num); - return 1; -} - -static int -rndr_math(hoedown_buffer *ob, const hoedown_buffer *text, int displaymode, const hoedown_renderer_data *data) -{ - hoedown_buffer_put(ob, (const uint8_t *)(displaymode ? "\\[" : "\\("), 2); - escape_html(ob, text->data, text->size); - hoedown_buffer_put(ob, (const uint8_t *)(displaymode ? "\\]" : "\\)"), 2); - return 1; -} - -static void -toc_header(hoedown_buffer *ob, const hoedown_buffer *content, int level, const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state = data->opaque; - - if (level <= state->toc_data.nesting_level) { - /* set the level offset if this is the first header - * we're parsing for the document */ - if (state->toc_data.current_level == 0) - state->toc_data.level_offset = level - 1; - - level -= state->toc_data.level_offset; - - if (level > state->toc_data.current_level) { - while (level > state->toc_data.current_level) { - HOEDOWN_BUFPUTSL(ob, "
      \n
    • \n"); - state->toc_data.current_level++; - } - } else if (level < state->toc_data.current_level) { - HOEDOWN_BUFPUTSL(ob, "
    • \n"); - while (level < state->toc_data.current_level) { - HOEDOWN_BUFPUTSL(ob, "
    \n\n"); - state->toc_data.current_level--; - } - HOEDOWN_BUFPUTSL(ob,"
  • \n"); - } else { - HOEDOWN_BUFPUTSL(ob,"
  • \n
  • \n"); - } - - hoedown_buffer_printf(ob, "", state->toc_data.header_count++); - if (content) hoedown_buffer_put(ob, content->data, content->size); - HOEDOWN_BUFPUTSL(ob, "\n"); - } -} - -static int -toc_link(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_buffer *link, const hoedown_buffer *title, const hoedown_renderer_data *data) -{ - if (content && content->size) hoedown_buffer_put(ob, content->data, content->size); - return 1; -} - -static void -toc_finalize(hoedown_buffer *ob, int inline_render, const hoedown_renderer_data *data) -{ - hoedown_html_renderer_state *state; - - if (inline_render) - return; - - state = data->opaque; - - while (state->toc_data.current_level > 0) { - HOEDOWN_BUFPUTSL(ob, "
  • \n\n"); - state->toc_data.current_level--; - } - - state->toc_data.header_count = 0; -} - -hoedown_renderer * -hoedown_html_toc_renderer_new(int nesting_level) -{ - static const hoedown_renderer cb_default = { - NULL, - - NULL, - NULL, - toc_header, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - - NULL, - rndr_codespan, - rndr_double_emphasis, - rndr_emphasis, - rndr_underline, - rndr_highlight, - rndr_quote, - NULL, - NULL, - toc_link, - rndr_triple_emphasis, - rndr_strikethrough, - rndr_superscript, - NULL, - NULL, - NULL, - - NULL, - rndr_normal_text, - - NULL, - toc_finalize - }; - - hoedown_html_renderer_state *state; - hoedown_renderer *renderer; - - /* Prepare the state pointer */ - state = hoedown_malloc(sizeof(hoedown_html_renderer_state)); - memset(state, 0x0, sizeof(hoedown_html_renderer_state)); - - state->toc_data.nesting_level = nesting_level; - - /* Prepare the renderer */ - renderer = hoedown_malloc(sizeof(hoedown_renderer)); - memcpy(renderer, &cb_default, sizeof(hoedown_renderer)); - - renderer->opaque = state; - return renderer; -} - -hoedown_renderer * -hoedown_html_renderer_new(hoedown_html_flags render_flags, int nesting_level) -{ - static const hoedown_renderer cb_default = { - NULL, - - rndr_blockcode, - rndr_blockquote, - rndr_header, - rndr_hrule, - rndr_list, - rndr_listitem, - rndr_paragraph, - rndr_table, - rndr_table_header, - rndr_table_body, - rndr_tablerow, - rndr_tablecell, - rndr_footnotes, - rndr_footnote_def, - rndr_raw_block, - - rndr_autolink, - rndr_codespan, - rndr_double_emphasis, - rndr_emphasis, - rndr_underline, - rndr_highlight, - rndr_quote, - rndr_image, - rndr_linebreak, - rndr_link, - rndr_triple_emphasis, - rndr_strikethrough, - rndr_superscript, - rndr_footnote_ref, - rndr_math, - rndr_raw_html, - - NULL, - rndr_normal_text, - - NULL, - NULL - }; - - hoedown_html_renderer_state *state; - hoedown_renderer *renderer; - - /* Prepare the state pointer */ - state = hoedown_malloc(sizeof(hoedown_html_renderer_state)); - memset(state, 0x0, sizeof(hoedown_html_renderer_state)); - - state->flags = render_flags; - state->toc_data.nesting_level = nesting_level; - - /* Prepare the renderer */ - renderer = hoedown_malloc(sizeof(hoedown_renderer)); - memcpy(renderer, &cb_default, sizeof(hoedown_renderer)); - - if (render_flags & HOEDOWN_HTML_SKIP_HTML || render_flags & HOEDOWN_HTML_ESCAPE) - renderer->blockhtml = NULL; - - renderer->opaque = state; - return renderer; -} - -void -hoedown_html_renderer_free(hoedown_renderer *renderer) -{ - free(renderer->opaque); - free(renderer); -} diff --git a/Sources/CHoedown/html_blocks.c b/Sources/CHoedown/html_blocks.c deleted file mode 100644 index f5e9dce..0000000 --- a/Sources/CHoedown/html_blocks.c +++ /dev/null @@ -1,240 +0,0 @@ -/* ANSI-C code produced by gperf version 3.0.3 */ -/* Command-line: gperf -L ANSI-C -N hoedown_find_block_tag -c -C -E -S 1 --ignore-case -m100 html_block_names.gperf */ -/* Computed positions: -k'1-2' */ - -#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ - && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ - && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ - && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ - && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ - && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ - && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ - && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ - && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ - && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ - && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ - && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ - && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ - && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ - && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ - && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ - && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ - && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ - && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ - && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ - && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ - && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ - && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) -/* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." -#endif - -/* maximum key range = 24, duplicates = 0 */ - -#ifndef GPERF_DOWNCASE -#define GPERF_DOWNCASE 1 -static unsigned char gperf_downcase[256] = - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, - 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, - 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, - 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, - 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, - 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, - 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, - 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, - 255 - }; -#endif - -#ifndef GPERF_CASE_STRNCMP -#define GPERF_CASE_STRNCMP 1 -static int -gperf_case_strncmp (register const char *s1, register const char *s2, register unsigned int n) -{ - for (; n > 0;) - { - unsigned char c1 = gperf_downcase[(unsigned char)*s1++]; - unsigned char c2 = gperf_downcase[(unsigned char)*s2++]; - if (c1 != 0 && c1 == c2) - { - n--; - continue; - } - return (int)c1 - (int)c2; - } - return 0; -} -#endif - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static unsigned int -hash (register const char *str, register unsigned int len) -{ - static const unsigned char asso_values[] = - { - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 22, 21, 19, 18, 16, 0, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 1, 25, 0, 25, - 1, 0, 0, 13, 0, 25, 25, 11, 2, 1, - 0, 25, 25, 5, 0, 2, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 1, 25, - 0, 25, 1, 0, 0, 13, 0, 25, 25, 11, - 2, 1, 0, 25, 25, 5, 0, 2, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25 - }; - register int hval = (int)len; - - switch (hval) - { - default: - hval += asso_values[(unsigned char)str[1]+1]; - /*FALLTHROUGH*/ - case 1: - hval += asso_values[(unsigned char)str[0]]; - break; - } - return hval; -} - -#ifdef __GNUC__ -__inline -#ifdef __GNUC_STDC_INLINE__ -__attribute__ ((__gnu_inline__)) -#endif -#endif -const char * -hoedown_find_block_tag (register const char *str, register unsigned int len) -{ - enum - { - TOTAL_KEYWORDS = 24, - MIN_WORD_LENGTH = 1, - MAX_WORD_LENGTH = 10, - MIN_HASH_VALUE = 1, - MAX_HASH_VALUE = 24 - }; - - if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) - { - register int key = hash (str, len); - - if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE) - { - register const char *resword; - - switch (key - 1) - { - case 0: - resword = "p"; - goto compare; - case 1: - resword = "h6"; - goto compare; - case 2: - resword = "div"; - goto compare; - case 3: - resword = "del"; - goto compare; - case 4: - resword = "form"; - goto compare; - case 5: - resword = "table"; - goto compare; - case 6: - resword = "figure"; - goto compare; - case 7: - resword = "pre"; - goto compare; - case 8: - resword = "fieldset"; - goto compare; - case 9: - resword = "noscript"; - goto compare; - case 10: - resword = "script"; - goto compare; - case 11: - resword = "style"; - goto compare; - case 12: - resword = "dl"; - goto compare; - case 13: - resword = "ol"; - goto compare; - case 14: - resword = "ul"; - goto compare; - case 15: - resword = "math"; - goto compare; - case 16: - resword = "ins"; - goto compare; - case 17: - resword = "h5"; - goto compare; - case 18: - resword = "iframe"; - goto compare; - case 19: - resword = "h4"; - goto compare; - case 20: - resword = "h3"; - goto compare; - case 21: - resword = "blockquote"; - goto compare; - case 22: - resword = "h2"; - goto compare; - case 23: - resword = "h1"; - goto compare; - } - return 0; - compare: - if ((((unsigned char)*str ^ (unsigned char)*resword) & ~32) == 0 && !gperf_case_strncmp (str, resword, len) && resword[len] == '\0') - return resword; - } - } - return 0; -} diff --git a/Sources/CHoedown/html_smartypants.c b/Sources/CHoedown/html_smartypants.c deleted file mode 100644 index e3dfa28..0000000 --- a/Sources/CHoedown/html_smartypants.c +++ /dev/null @@ -1,435 +0,0 @@ -#include "html.h" - -#include -#include -#include -#include - -#ifdef _MSC_VER -#define snprintf _snprintf -#endif - -struct smartypants_data { - int in_squote; - int in_dquote; -}; - -static size_t smartypants_cb__ltag(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size); -static size_t smartypants_cb__dquote(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size); -static size_t smartypants_cb__amp(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size); -static size_t smartypants_cb__period(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size); -static size_t smartypants_cb__number(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size); -static size_t smartypants_cb__dash(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size); -static size_t smartypants_cb__parens(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size); -static size_t smartypants_cb__squote(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size); -static size_t smartypants_cb__backtick(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size); -static size_t smartypants_cb__escape(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size); - -static size_t (*smartypants_cb_ptrs[]) - (hoedown_buffer *, struct smartypants_data *, uint8_t, const uint8_t *, size_t) = -{ - NULL, /* 0 */ - smartypants_cb__dash, /* 1 */ - smartypants_cb__parens, /* 2 */ - smartypants_cb__squote, /* 3 */ - smartypants_cb__dquote, /* 4 */ - smartypants_cb__amp, /* 5 */ - smartypants_cb__period, /* 6 */ - smartypants_cb__number, /* 7 */ - smartypants_cb__ltag, /* 8 */ - smartypants_cb__backtick, /* 9 */ - smartypants_cb__escape, /* 10 */ -}; - -static const uint8_t smartypants_cb_chars[UINT8_MAX+1] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 0, 0, 0, 5, 3, 2, 0, 0, 0, 0, 1, 6, 0, - 0, 7, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static int -word_boundary(uint8_t c) -{ - return c == 0 || isspace(c) || ispunct(c); -} - -/* - If 'text' begins with any kind of single quote (e.g. "'" or "'" etc.), - returns the length of the sequence of characters that makes up the single- - quote. Otherwise, returns zero. -*/ -static size_t -squote_len(const uint8_t *text, size_t size) -{ - static char* single_quote_list[] = { "'", "'", "'", "'", NULL }; - char** p; - - for (p = single_quote_list; *p; ++p) { - size_t len = strlen(*p); - if (size >= len && memcmp(text, *p, len) == 0) { - return len; - } - } - - return 0; -} - -/* Converts " or ' at very beginning or end of a word to left or right quote */ -static int -smartypants_quotes(hoedown_buffer *ob, uint8_t previous_char, uint8_t next_char, uint8_t quote, int *is_open) -{ - char ent[8]; - - if (*is_open && !word_boundary(next_char)) - return 0; - - if (!(*is_open) && !word_boundary(previous_char)) - return 0; - - snprintf(ent, sizeof(ent), "&%c%cquo;", (*is_open) ? 'r' : 'l', quote); - *is_open = !(*is_open); - hoedown_buffer_puts(ob, ent); - return 1; -} - -/* - Converts ' to left or right single quote; but the initial ' might be in - different forms, e.g. ' or ' or '. - 'squote_text' points to the original single quote, and 'squote_size' is its length. - 'text' points at the last character of the single-quote, e.g. ' or ; -*/ -static size_t -smartypants_squote(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size, - const uint8_t *squote_text, size_t squote_size) -{ - if (size >= 2) { - uint8_t t1 = tolower(text[1]); - size_t next_squote_len = squote_len(text+1, size-1); - - /* convert '' to “ or ” */ - if (next_squote_len > 0) { - uint8_t next_char = (size > 1+next_squote_len) ? text[1+next_squote_len] : 0; - if (smartypants_quotes(ob, previous_char, next_char, 'd', &smrt->in_dquote)) - return next_squote_len; - } - - /* Tom's, isn't, I'm, I'd */ - if ((t1 == 's' || t1 == 't' || t1 == 'm' || t1 == 'd') && - (size == 3 || word_boundary(text[2]))) { - HOEDOWN_BUFPUTSL(ob, "’"); - return 0; - } - - /* you're, you'll, you've */ - if (size >= 3) { - uint8_t t2 = tolower(text[2]); - - if (((t1 == 'r' && t2 == 'e') || - (t1 == 'l' && t2 == 'l') || - (t1 == 'v' && t2 == 'e')) && - (size == 4 || word_boundary(text[3]))) { - HOEDOWN_BUFPUTSL(ob, "’"); - return 0; - } - } - } - - if (smartypants_quotes(ob, previous_char, size > 0 ? text[1] : 0, 's', &smrt->in_squote)) - return 0; - - hoedown_buffer_put(ob, squote_text, squote_size); - return 0; -} - -/* Converts ' to left or right single quote. */ -static size_t -smartypants_cb__squote(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size) -{ - return smartypants_squote(ob, smrt, previous_char, text, size, text, 1); -} - -/* Converts (c), (r), (tm) */ -static size_t -smartypants_cb__parens(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size) -{ - if (size >= 3) { - uint8_t t1 = tolower(text[1]); - uint8_t t2 = tolower(text[2]); - - if (t1 == 'c' && t2 == ')') { - HOEDOWN_BUFPUTSL(ob, "©"); - return 2; - } - - if (t1 == 'r' && t2 == ')') { - HOEDOWN_BUFPUTSL(ob, "®"); - return 2; - } - - if (size >= 4 && t1 == 't' && t2 == 'm' && text[3] == ')') { - HOEDOWN_BUFPUTSL(ob, "™"); - return 3; - } - } - - hoedown_buffer_putc(ob, text[0]); - return 0; -} - -/* Converts "--" to em-dash, etc. */ -static size_t -smartypants_cb__dash(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size) -{ - if (size >= 3 && text[1] == '-' && text[2] == '-') { - HOEDOWN_BUFPUTSL(ob, "—"); - return 2; - } - - if (size >= 2 && text[1] == '-') { - HOEDOWN_BUFPUTSL(ob, "–"); - return 1; - } - - hoedown_buffer_putc(ob, text[0]); - return 0; -} - -/* Converts " etc. */ -static size_t -smartypants_cb__amp(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size) -{ - size_t len; - if (size >= 6 && memcmp(text, """, 6) == 0) { - if (smartypants_quotes(ob, previous_char, size >= 7 ? text[6] : 0, 'd', &smrt->in_dquote)) - return 5; - } - - len = squote_len(text, size); - if (len > 0) { - return (len-1) + smartypants_squote(ob, smrt, previous_char, text+(len-1), size-(len-1), text, len); - } - - if (size >= 4 && memcmp(text, "�", 4) == 0) - return 3; - - hoedown_buffer_putc(ob, '&'); - return 0; -} - -/* Converts "..." to ellipsis */ -static size_t -smartypants_cb__period(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size) -{ - if (size >= 3 && text[1] == '.' && text[2] == '.') { - HOEDOWN_BUFPUTSL(ob, "…"); - return 2; - } - - if (size >= 5 && text[1] == ' ' && text[2] == '.' && text[3] == ' ' && text[4] == '.') { - HOEDOWN_BUFPUTSL(ob, "…"); - return 4; - } - - hoedown_buffer_putc(ob, text[0]); - return 0; -} - -/* Converts `` to opening double quote */ -static size_t -smartypants_cb__backtick(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size) -{ - if (size >= 2 && text[1] == '`') { - if (smartypants_quotes(ob, previous_char, size >= 3 ? text[2] : 0, 'd', &smrt->in_dquote)) - return 1; - } - - hoedown_buffer_putc(ob, text[0]); - return 0; -} - -/* Converts 1/2, 1/4, 3/4 */ -static size_t -smartypants_cb__number(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size) -{ - if (word_boundary(previous_char) && size >= 3) { - if (text[0] == '1' && text[1] == '/' && text[2] == '2') { - if (size == 3 || word_boundary(text[3])) { - HOEDOWN_BUFPUTSL(ob, "½"); - return 2; - } - } - - if (text[0] == '1' && text[1] == '/' && text[2] == '4') { - if (size == 3 || word_boundary(text[3]) || - (size >= 5 && tolower(text[3]) == 't' && tolower(text[4]) == 'h')) { - HOEDOWN_BUFPUTSL(ob, "¼"); - return 2; - } - } - - if (text[0] == '3' && text[1] == '/' && text[2] == '4') { - if (size == 3 || word_boundary(text[3]) || - (size >= 6 && tolower(text[3]) == 't' && tolower(text[4]) == 'h' && tolower(text[5]) == 's')) { - HOEDOWN_BUFPUTSL(ob, "¾"); - return 2; - } - } - } - - hoedown_buffer_putc(ob, text[0]); - return 0; -} - -/* Converts " to left or right double quote */ -static size_t -smartypants_cb__dquote(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size) -{ - if (!smartypants_quotes(ob, previous_char, size > 0 ? text[1] : 0, 'd', &smrt->in_dquote)) - HOEDOWN_BUFPUTSL(ob, """); - - return 0; -} - -static size_t -smartypants_cb__ltag(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size) -{ - static const char *skip_tags[] = { - "pre", "code", "var", "samp", "kbd", "math", "script", "style" - }; - static const size_t skip_tags_count = 8; - - size_t tag, i = 0; - - /* This is a comment. Copy everything verbatim until --> or EOF is seen. */ - if (i + 4 < size && memcmp(text + i, "", 3) != 0) - i++; - i += 3; - hoedown_buffer_put(ob, text, i + 1); - return i; - } - - while (i < size && text[i] != '>') - i++; - - for (tag = 0; tag < skip_tags_count; ++tag) { - if (hoedown_html_is_tag(text, size, skip_tags[tag]) == HOEDOWN_HTML_TAG_OPEN) - break; - } - - if (tag < skip_tags_count) { - for (;;) { - while (i < size && text[i] != '<') - i++; - - if (i == size) - break; - - if (hoedown_html_is_tag(text + i, size - i, skip_tags[tag]) == HOEDOWN_HTML_TAG_CLOSE) - break; - - i++; - } - - while (i < size && text[i] != '>') - i++; - } - - hoedown_buffer_put(ob, text, i + 1); - return i; -} - -static size_t -smartypants_cb__escape(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size) -{ - if (size < 2) - return 0; - - switch (text[1]) { - case '\\': - case '"': - case '\'': - case '.': - case '-': - case '`': - hoedown_buffer_putc(ob, text[1]); - return 1; - - default: - hoedown_buffer_putc(ob, '\\'); - return 0; - } -} - -#if 0 -static struct { - uint8_t c0; - const uint8_t *pattern; - const uint8_t *entity; - int skip; -} smartypants_subs[] = { - { '\'', "'s>", "’", 0 }, - { '\'', "'t>", "’", 0 }, - { '\'', "'re>", "’", 0 }, - { '\'', "'ll>", "’", 0 }, - { '\'', "'ve>", "’", 0 }, - { '\'', "'m>", "’", 0 }, - { '\'', "'d>", "’", 0 }, - { '-', "--", "—", 1 }, - { '-', "<->", "–", 0 }, - { '.', "...", "…", 2 }, - { '.', ". . .", "…", 4 }, - { '(', "(c)", "©", 2 }, - { '(', "(r)", "®", 2 }, - { '(', "(tm)", "™", 3 }, - { '3', "<3/4>", "¾", 2 }, - { '3', "<3/4ths>", "¾", 2 }, - { '1', "<1/2>", "½", 2 }, - { '1', "<1/4>", "¼", 2 }, - { '1', "<1/4th>", "¼", 2 }, - { '&', "�", 0, 3 }, -}; -#endif - -void -hoedown_html_smartypants(hoedown_buffer *ob, const uint8_t *text, size_t size) -{ - size_t i; - struct smartypants_data smrt = {0, 0}; - - if (!text) - return; - - hoedown_buffer_grow(ob, size); - - for (i = 0; i < size; ++i) { - size_t org; - uint8_t action = 0; - - org = i; - while (i < size && (action = smartypants_cb_chars[text[i]]) == 0) - i++; - - if (i > org) - hoedown_buffer_put(ob, text + org, i - org); - - if (i < size) { - i += smartypants_cb_ptrs[(int)action] - (ob, &smrt, i ? text[i - 1] : 0, text + i, size - i); - } - } -} diff --git a/Sources/CHoedown/include/autolink.h b/Sources/CHoedown/include/autolink.h deleted file mode 100644 index 528885c..0000000 --- a/Sources/CHoedown/include/autolink.h +++ /dev/null @@ -1,46 +0,0 @@ -/* autolink.h - versatile autolinker */ - -#ifndef HOEDOWN_AUTOLINK_H -#define HOEDOWN_AUTOLINK_H - -#include "buffer.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/************* - * CONSTANTS * - *************/ - -typedef enum hoedown_autolink_flags { - HOEDOWN_AUTOLINK_SHORT_DOMAINS = (1 << 0) -} hoedown_autolink_flags; - - -/************* - * FUNCTIONS * - *************/ - -/* hoedown_autolink_is_safe: verify that a URL has a safe protocol */ -int hoedown_autolink_is_safe(const uint8_t *data, size_t size); - -/* hoedown_autolink__www: search for the next www link in data */ -size_t hoedown_autolink__www(size_t *rewind_p, hoedown_buffer *link, - uint8_t *data, size_t offset, size_t size, hoedown_autolink_flags flags); - -/* hoedown_autolink__email: search for the next email in data */ -size_t hoedown_autolink__email(size_t *rewind_p, hoedown_buffer *link, - uint8_t *data, size_t offset, size_t size, hoedown_autolink_flags flags); - -/* hoedown_autolink__url: search for the next URL in data */ -size_t hoedown_autolink__url(size_t *rewind_p, hoedown_buffer *link, - uint8_t *data, size_t offset, size_t size, hoedown_autolink_flags flags); - - -#ifdef __cplusplus -} -#endif - -#endif /** HOEDOWN_AUTOLINK_H **/ diff --git a/Sources/CHoedown/include/buffer.h b/Sources/CHoedown/include/buffer.h deleted file mode 100644 index d7703f8..0000000 --- a/Sources/CHoedown/include/buffer.h +++ /dev/null @@ -1,134 +0,0 @@ -/* buffer.h - simple, fast buffers */ - -#ifndef HOEDOWN_BUFFER_H -#define HOEDOWN_BUFFER_H - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(_MSC_VER) -#define __attribute__(x) -#define inline __inline -#define __builtin_expect(x,n) x -#endif - - -/********* - * TYPES * - *********/ - -typedef void *(*hoedown_realloc_callback)(void *, size_t); -typedef void (*hoedown_free_callback)(void *); - -struct hoedown_buffer { - uint8_t *data; /* actual character data */ - size_t size; /* size of the string */ - size_t asize; /* allocated size (0 = volatile buffer) */ - size_t unit; /* reallocation unit size (0 = read-only buffer) */ - - hoedown_realloc_callback data_realloc; - hoedown_free_callback data_free; - hoedown_free_callback buffer_free; -}; - -typedef struct hoedown_buffer hoedown_buffer; - - -/************* - * FUNCTIONS * - *************/ - -/* allocation wrappers */ -void *hoedown_malloc(size_t size) __attribute__ ((malloc)); -void *hoedown_calloc(size_t nmemb, size_t size) __attribute__ ((malloc)); -void *hoedown_realloc(void *ptr, size_t size) __attribute__ ((malloc)); - -/* hoedown_buffer_init: initialize a buffer with custom allocators */ -void hoedown_buffer_init( - hoedown_buffer *buffer, - size_t unit, - hoedown_realloc_callback data_realloc, - hoedown_free_callback data_free, - hoedown_free_callback buffer_free -); - -/* hoedown_buffer_uninit: uninitialize an existing buffer */ -void hoedown_buffer_uninit(hoedown_buffer *buf); - -/* hoedown_buffer_new: allocate a new buffer */ -hoedown_buffer *hoedown_buffer_new(size_t unit) __attribute__ ((malloc)); - -/* hoedown_buffer_reset: free internal data of the buffer */ -void hoedown_buffer_reset(hoedown_buffer *buf); - -/* hoedown_buffer_grow: increase the allocated size to the given value */ -void hoedown_buffer_grow(hoedown_buffer *buf, size_t neosz); - -/* hoedown_buffer_put: append raw data to a buffer */ -void hoedown_buffer_put(hoedown_buffer *buf, const uint8_t *data, size_t size); - -/* hoedown_buffer_puts: append a NUL-terminated string to a buffer */ -void hoedown_buffer_puts(hoedown_buffer *buf, const char *str); - -/* hoedown_buffer_putc: append a single char to a buffer */ -void hoedown_buffer_putc(hoedown_buffer *buf, uint8_t c); - -/* hoedown_buffer_putf: read from a file and append to a buffer, until EOF or error */ -int hoedown_buffer_putf(hoedown_buffer *buf, FILE* file); - -/* hoedown_buffer_set: replace the buffer's contents with raw data */ -void hoedown_buffer_set(hoedown_buffer *buf, const uint8_t *data, size_t size); - -/* hoedown_buffer_sets: replace the buffer's contents with a NUL-terminated string */ -void hoedown_buffer_sets(hoedown_buffer *buf, const char *str); - -/* hoedown_buffer_eq: compare a buffer's data with other data for equality */ -int hoedown_buffer_eq(const hoedown_buffer *buf, const uint8_t *data, size_t size); - -/* hoedown_buffer_eq: compare a buffer's data with NUL-terminated string for equality */ -int hoedown_buffer_eqs(const hoedown_buffer *buf, const char *str); - -/* hoedown_buffer_prefix: compare the beginning of a buffer with a string */ -int hoedown_buffer_prefix(const hoedown_buffer *buf, const char *prefix); - -/* hoedown_buffer_slurp: remove a given number of bytes from the head of the buffer */ -void hoedown_buffer_slurp(hoedown_buffer *buf, size_t size); - -/* hoedown_buffer_cstr: NUL-termination of the string array (making a C-string) */ -const char *hoedown_buffer_cstr(hoedown_buffer *buf); - -/* hoedown_buffer_printf: formatted printing to a buffer */ -void hoedown_buffer_printf(hoedown_buffer *buf, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); - -/* hoedown_buffer_put_utf8: put a Unicode character encoded as UTF-8 */ -void hoedown_buffer_put_utf8(hoedown_buffer *buf, unsigned int codepoint); - -/* hoedown_buffer_free: free the buffer */ -void hoedown_buffer_free(hoedown_buffer *buf); - - -/* HOEDOWN_BUFPUTSL: optimized hoedown_buffer_puts of a string literal */ -#define HOEDOWN_BUFPUTSL(output, literal) \ - hoedown_buffer_put(output, (const uint8_t *)literal, sizeof(literal) - 1) - -/* HOEDOWN_BUFSETSL: optimized hoedown_buffer_sets of a string literal */ -#define HOEDOWN_BUFSETSL(output, literal) \ - hoedown_buffer_set(output, (const uint8_t *)literal, sizeof(literal) - 1) - -/* HOEDOWN_BUFEQSL: optimized hoedown_buffer_eqs of a string literal */ -#define HOEDOWN_BUFEQSL(output, literal) \ - hoedown_buffer_eq(output, (const uint8_t *)literal, sizeof(literal) - 1) - - -#ifdef __cplusplus -} -#endif - -#endif /** HOEDOWN_BUFFER_H **/ diff --git a/Sources/CHoedown/include/document.h b/Sources/CHoedown/include/document.h deleted file mode 100644 index a8178fe..0000000 --- a/Sources/CHoedown/include/document.h +++ /dev/null @@ -1,172 +0,0 @@ -/* document.h - generic markdown parser */ - -#ifndef HOEDOWN_DOCUMENT_H -#define HOEDOWN_DOCUMENT_H - -#include "buffer.h" -#include "autolink.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/************* - * CONSTANTS * - *************/ - -typedef enum hoedown_extensions { - /* block-level extensions */ - HOEDOWN_EXT_TABLES = (1 << 0), - HOEDOWN_EXT_FENCED_CODE = (1 << 1), - HOEDOWN_EXT_FOOTNOTES = (1 << 2), - - /* span-level extensions */ - HOEDOWN_EXT_AUTOLINK = (1 << 3), - HOEDOWN_EXT_STRIKETHROUGH = (1 << 4), - HOEDOWN_EXT_UNDERLINE = (1 << 5), - HOEDOWN_EXT_HIGHLIGHT = (1 << 6), - HOEDOWN_EXT_QUOTE = (1 << 7), - HOEDOWN_EXT_SUPERSCRIPT = (1 << 8), - HOEDOWN_EXT_MATH = (1 << 9), - - /* other flags */ - HOEDOWN_EXT_NO_INTRA_EMPHASIS = (1 << 11), - HOEDOWN_EXT_SPACE_HEADERS = (1 << 12), - HOEDOWN_EXT_MATH_EXPLICIT = (1 << 13), - - /* negative flags */ - HOEDOWN_EXT_DISABLE_INDENTED_CODE = (1 << 14) -} hoedown_extensions; - -#define HOEDOWN_EXT_BLOCK (\ - HOEDOWN_EXT_TABLES |\ - HOEDOWN_EXT_FENCED_CODE |\ - HOEDOWN_EXT_FOOTNOTES ) - -#define HOEDOWN_EXT_SPAN (\ - HOEDOWN_EXT_AUTOLINK |\ - HOEDOWN_EXT_STRIKETHROUGH |\ - HOEDOWN_EXT_UNDERLINE |\ - HOEDOWN_EXT_HIGHLIGHT |\ - HOEDOWN_EXT_QUOTE |\ - HOEDOWN_EXT_SUPERSCRIPT |\ - HOEDOWN_EXT_MATH ) - -#define HOEDOWN_EXT_FLAGS (\ - HOEDOWN_EXT_NO_INTRA_EMPHASIS |\ - HOEDOWN_EXT_SPACE_HEADERS |\ - HOEDOWN_EXT_MATH_EXPLICIT ) - -#define HOEDOWN_EXT_NEGATIVE (\ - HOEDOWN_EXT_DISABLE_INDENTED_CODE ) - -typedef enum hoedown_list_flags { - HOEDOWN_LIST_ORDERED = (1 << 0), - HOEDOWN_LI_BLOCK = (1 << 1) /*
  • containing block data */ -} hoedown_list_flags; - -typedef enum hoedown_table_flags { - HOEDOWN_TABLE_ALIGN_LEFT = 1, - HOEDOWN_TABLE_ALIGN_RIGHT = 2, - HOEDOWN_TABLE_ALIGN_CENTER = 3, - HOEDOWN_TABLE_ALIGNMASK = 3, - HOEDOWN_TABLE_HEADER = 4 -} hoedown_table_flags; - -typedef enum hoedown_autolink_type { - HOEDOWN_AUTOLINK_NONE, /* used internally when it is not an autolink*/ - HOEDOWN_AUTOLINK_NORMAL, /* normal http/http/ftp/mailto/etc link */ - HOEDOWN_AUTOLINK_EMAIL /* e-mail link without explit mailto: */ -} hoedown_autolink_type; - - -/********* - * TYPES * - *********/ - -struct hoedown_document; -typedef struct hoedown_document hoedown_document; - -struct hoedown_renderer_data { - void *opaque; -}; -typedef struct hoedown_renderer_data hoedown_renderer_data; - -/* hoedown_renderer - functions for rendering parsed data */ -struct hoedown_renderer { - /* state object */ - void *opaque; - - /* block level callbacks - NULL skips the block */ - void (*blockcode)(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_buffer *lang, const hoedown_renderer_data *data); - void (*blockquote)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - void (*header)(hoedown_buffer *ob, const hoedown_buffer *content, int level, const hoedown_renderer_data *data); - void (*hrule)(hoedown_buffer *ob, const hoedown_renderer_data *data); - void (*list)(hoedown_buffer *ob, const hoedown_buffer *content, hoedown_list_flags flags, const hoedown_renderer_data *data); - void (*listitem)(hoedown_buffer *ob, const hoedown_buffer *content, hoedown_list_flags flags, const hoedown_renderer_data *data); - void (*paragraph)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - void (*table)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - void (*table_header)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - void (*table_body)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - void (*table_row)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - void (*table_cell)(hoedown_buffer *ob, const hoedown_buffer *content, hoedown_table_flags flags, const hoedown_renderer_data *data); - void (*footnotes)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - void (*footnote_def)(hoedown_buffer *ob, const hoedown_buffer *content, unsigned int num, const hoedown_renderer_data *data); - void (*blockhtml)(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_renderer_data *data); - - /* span level callbacks - NULL or return 0 prints the span verbatim */ - int (*autolink)(hoedown_buffer *ob, const hoedown_buffer *link, hoedown_autolink_type type, const hoedown_renderer_data *data); - int (*codespan)(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_renderer_data *data); - int (*double_emphasis)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - int (*emphasis)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - int (*underline)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - int (*highlight)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - int (*quote)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - int (*image)(hoedown_buffer *ob, const hoedown_buffer *link, const hoedown_buffer *title, const hoedown_buffer *alt, const hoedown_renderer_data *data); - int (*linebreak)(hoedown_buffer *ob, const hoedown_renderer_data *data); - int (*link)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_buffer *link, const hoedown_buffer *title, const hoedown_renderer_data *data); - int (*triple_emphasis)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - int (*strikethrough)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - int (*superscript)(hoedown_buffer *ob, const hoedown_buffer *content, const hoedown_renderer_data *data); - int (*footnote_ref)(hoedown_buffer *ob, unsigned int num, const hoedown_renderer_data *data); - int (*math)(hoedown_buffer *ob, const hoedown_buffer *text, int displaymode, const hoedown_renderer_data *data); - int (*raw_html)(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_renderer_data *data); - - /* low level callbacks - NULL copies input directly into the output */ - void (*entity)(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_renderer_data *data); - void (*normal_text)(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_renderer_data *data); - - /* miscellaneous callbacks */ - void (*doc_header)(hoedown_buffer *ob, int inline_render, const hoedown_renderer_data *data); - void (*doc_footer)(hoedown_buffer *ob, int inline_render, const hoedown_renderer_data *data); -}; -typedef struct hoedown_renderer hoedown_renderer; - - -/************* - * FUNCTIONS * - *************/ - -/* hoedown_document_new: allocate a new document processor instance */ -hoedown_document *hoedown_document_new( - const hoedown_renderer *renderer, - hoedown_extensions extensions, - size_t max_nesting -) __attribute__ ((malloc)); - -/* hoedown_document_render: render regular Markdown using the document processor */ -void hoedown_document_render(hoedown_document *doc, hoedown_buffer *ob, const uint8_t *data, size_t size); - -/* hoedown_document_render_inline: render inline Markdown using the document processor */ -void hoedown_document_render_inline(hoedown_document *doc, hoedown_buffer *ob, const uint8_t *data, size_t size); - -/* hoedown_document_free: deallocate a document processor instance */ -void hoedown_document_free(hoedown_document *doc); - - -#ifdef __cplusplus -} -#endif - -#endif /** HOEDOWN_DOCUMENT_H **/ diff --git a/Sources/CHoedown/include/escape.h b/Sources/CHoedown/include/escape.h deleted file mode 100644 index d7659c2..0000000 --- a/Sources/CHoedown/include/escape.h +++ /dev/null @@ -1,28 +0,0 @@ -/* escape.h - escape utilities */ - -#ifndef HOEDOWN_ESCAPE_H -#define HOEDOWN_ESCAPE_H - -#include "buffer.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/************* - * FUNCTIONS * - *************/ - -/* hoedown_escape_href: escape (part of) a URL inside HTML */ -void hoedown_escape_href(hoedown_buffer *ob, const uint8_t *data, size_t size); - -/* hoedown_escape_html: escape HTML */ -void hoedown_escape_html(hoedown_buffer *ob, const uint8_t *data, size_t size, int secure); - - -#ifdef __cplusplus -} -#endif - -#endif /** HOEDOWN_ESCAPE_H **/ diff --git a/Sources/CHoedown/include/hoedown_html_patch.h b/Sources/CHoedown/include/hoedown_html_patch.h deleted file mode 100644 index 86b7b44..0000000 --- a/Sources/CHoedown/include/hoedown_html_patch.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// hoedown_html_patch.h -// MacDown -// -// Created by Tzu-ping Chung on 14/06/2014. -// Copyright (c) 2014 Tzu-ping Chung . All rights reserved. -// - -#ifndef MacDown_hoedown_html_patch_h -#define MacDown_hoedown_html_patch_h - -#include "buffer.h" -#include "document.h" -#include "html.h" - -// Extra renderer flags, occupying bits unused by hoedown_html_flags. -enum { - HOEDOWN_HTML_USE_TASK_LIST = (1 << 4), - HOEDOWN_HTML_BLOCKCODE_LINE_NUMBERS = (1 << 5), - HOEDOWN_HTML_BLOCKCODE_INFORMATION = (1 << 6), -}; - -typedef struct hoedown_html_renderer_state_extra { - - /* More extra callbacks */ - hoedown_buffer *(*language_addition)(const hoedown_buffer *language, - void *owner); - void *owner; - -} hoedown_html_renderer_state_extra; - -void hoedown_patch_render_blockcode( - hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_buffer *lang, - const hoedown_renderer_data *data); - -void hoedown_patch_render_listitem( - hoedown_buffer *ob, const hoedown_buffer *text, hoedown_list_flags flags, - const hoedown_renderer_data *data); - -void hoedown_patch_render_toc_header( - hoedown_buffer *ob, const hoedown_buffer *content, int level, - const hoedown_renderer_data *data); - -#endif diff --git a/Sources/CHoedown/include/html.h b/Sources/CHoedown/include/html.h deleted file mode 100644 index e46e7fd..0000000 --- a/Sources/CHoedown/include/html.h +++ /dev/null @@ -1,84 +0,0 @@ -/* html.h - HTML renderer and utilities */ - -#ifndef HOEDOWN_HTML_H -#define HOEDOWN_HTML_H - -#include "document.h" -#include "buffer.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/************* - * CONSTANTS * - *************/ - -typedef enum hoedown_html_flags { - HOEDOWN_HTML_SKIP_HTML = (1 << 0), - HOEDOWN_HTML_ESCAPE = (1 << 1), - HOEDOWN_HTML_HARD_WRAP = (1 << 2), - HOEDOWN_HTML_USE_XHTML = (1 << 3) -} hoedown_html_flags; - -typedef enum hoedown_html_tag { - HOEDOWN_HTML_TAG_NONE = 0, - HOEDOWN_HTML_TAG_OPEN, - HOEDOWN_HTML_TAG_CLOSE -} hoedown_html_tag; - - -/********* - * TYPES * - *********/ - -struct hoedown_html_renderer_state { - void *opaque; - - struct { - int header_count; - int current_level; - int level_offset; - int nesting_level; - } toc_data; - - hoedown_html_flags flags; - - /* extra callbacks */ - void (*link_attributes)(hoedown_buffer *ob, const hoedown_buffer *url, const hoedown_renderer_data *data); -}; -typedef struct hoedown_html_renderer_state hoedown_html_renderer_state; - - -/************* - * FUNCTIONS * - *************/ - -/* hoedown_html_smartypants: process an HTML snippet using SmartyPants for smart punctuation */ -void hoedown_html_smartypants(hoedown_buffer *ob, const uint8_t *data, size_t size); - -/* hoedown_html_is_tag: checks if data starts with a specific tag, returns the tag type or NONE */ -hoedown_html_tag hoedown_html_is_tag(const uint8_t *data, size_t size, const char *tagname); - - -/* hoedown_html_renderer_new: allocates a regular HTML renderer */ -hoedown_renderer *hoedown_html_renderer_new( - hoedown_html_flags render_flags, - int nesting_level -) __attribute__ ((malloc)); - -/* hoedown_html_toc_renderer_new: like hoedown_html_renderer_new, but the returned renderer produces the Table of Contents */ -hoedown_renderer *hoedown_html_toc_renderer_new( - int nesting_level -) __attribute__ ((malloc)); - -/* hoedown_html_renderer_free: deallocate an HTML renderer */ -void hoedown_html_renderer_free(hoedown_renderer *renderer); - - -#ifdef __cplusplus -} -#endif - -#endif /** HOEDOWN_HTML_H **/ diff --git a/Sources/CHoedown/include/module.modulemap b/Sources/CHoedown/include/module.modulemap deleted file mode 100644 index b5b1403..0000000 --- a/Sources/CHoedown/include/module.modulemap +++ /dev/null @@ -1,11 +0,0 @@ -module CHoedown { - header "buffer.h" - header "document.h" - header "escape.h" - header "html.h" - header "autolink.h" - header "stack.h" - header "version.h" - header "hoedown_html_patch.h" - export * -} diff --git a/Sources/CHoedown/include/stack.h b/Sources/CHoedown/include/stack.h deleted file mode 100644 index bf9b439..0000000 --- a/Sources/CHoedown/include/stack.h +++ /dev/null @@ -1,52 +0,0 @@ -/* stack.h - simple stacking */ - -#ifndef HOEDOWN_STACK_H -#define HOEDOWN_STACK_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/********* - * TYPES * - *********/ - -struct hoedown_stack { - void **item; - size_t size; - size_t asize; -}; -typedef struct hoedown_stack hoedown_stack; - - -/************* - * FUNCTIONS * - *************/ - -/* hoedown_stack_init: initialize a stack */ -void hoedown_stack_init(hoedown_stack *st, size_t initial_size); - -/* hoedown_stack_uninit: free internal data of the stack */ -void hoedown_stack_uninit(hoedown_stack *st); - -/* hoedown_stack_grow: increase the allocated size to the given value */ -void hoedown_stack_grow(hoedown_stack *st, size_t neosz); - -/* hoedown_stack_push: push an item to the top of the stack */ -void hoedown_stack_push(hoedown_stack *st, void *item); - -/* hoedown_stack_pop: retrieve and remove the item at the top of the stack */ -void *hoedown_stack_pop(hoedown_stack *st); - -/* hoedown_stack_top: retrieve the item at the top of the stack */ -void *hoedown_stack_top(const hoedown_stack *st); - - -#ifdef __cplusplus -} -#endif - -#endif /** HOEDOWN_STACK_H **/ diff --git a/Sources/CHoedown/include/version.h b/Sources/CHoedown/include/version.h deleted file mode 100644 index 62fb366..0000000 --- a/Sources/CHoedown/include/version.h +++ /dev/null @@ -1,33 +0,0 @@ -/* version.h - holds Hoedown's version */ - -#ifndef HOEDOWN_VERSION_H -#define HOEDOWN_VERSION_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/************* - * CONSTANTS * - *************/ - -#define HOEDOWN_VERSION "3.0.7" -#define HOEDOWN_VERSION_MAJOR 3 -#define HOEDOWN_VERSION_MINOR 0 -#define HOEDOWN_VERSION_REVISION 7 - - -/************* - * FUNCTIONS * - *************/ - -/* hoedown_version: retrieve Hoedown's version numbers */ -void hoedown_version(int *major, int *minor, int *revision); - - -#ifdef __cplusplus -} -#endif - -#endif /** HOEDOWN_VERSION_H **/ diff --git a/Sources/CHoedown/stack.c b/Sources/CHoedown/stack.c deleted file mode 100644 index 5c6102c..0000000 --- a/Sources/CHoedown/stack.c +++ /dev/null @@ -1,79 +0,0 @@ -#include "stack.h" - -#include "buffer.h" - -#include -#include -#include - -void -hoedown_stack_init(hoedown_stack *st, size_t initial_size) -{ - assert(st); - - st->item = NULL; - st->size = st->asize = 0; - - if (!initial_size) - initial_size = 8; - - hoedown_stack_grow(st, initial_size); -} - -void -hoedown_stack_uninit(hoedown_stack *st) -{ - assert(st); - - free(st->item); -} - -void -hoedown_stack_grow(hoedown_stack *st, size_t neosz) -{ - assert(st); - - if (st->asize >= neosz) - return; - - st->item = hoedown_realloc(st->item, neosz * sizeof(void *)); - memset(st->item + st->asize, 0x0, (neosz - st->asize) * sizeof(void *)); - - st->asize = neosz; - - if (st->size > neosz) - st->size = neosz; -} - -void -hoedown_stack_push(hoedown_stack *st, void *item) -{ - assert(st); - - if (st->size >= st->asize) - hoedown_stack_grow(st, st->size * 2); - - st->item[st->size++] = item; -} - -void * -hoedown_stack_pop(hoedown_stack *st) -{ - assert(st); - - if (!st->size) - return NULL; - - return st->item[--st->size]; -} - -void * -hoedown_stack_top(const hoedown_stack *st) -{ - assert(st); - - if (!st->size) - return NULL; - - return st->item[st->size - 1]; -} diff --git a/Sources/CHoedown/version.c b/Sources/CHoedown/version.c deleted file mode 100644 index 744209b..0000000 --- a/Sources/CHoedown/version.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "version.h" - -void -hoedown_version(int *major, int *minor, int *revision) -{ - *major = HOEDOWN_VERSION_MAJOR; - *minor = HOEDOWN_VERSION_MINOR; - *revision = HOEDOWN_VERSION_REVISION; -} diff --git a/Sources/CPegMarkdown/include/module.modulemap b/Sources/CPegMarkdown/include/module.modulemap deleted file mode 100644 index 7e20a16..0000000 --- a/Sources/CPegMarkdown/include/module.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -module CPegMarkdown { - header "pmh_definitions.h" - header "pmh_parser.h" - header "pmh_styleparser.h" - export * -} diff --git a/Sources/CPegMarkdown/include/pmh_definitions.h b/Sources/CPegMarkdown/include/pmh_definitions.h deleted file mode 100755 index d815d35..0000000 --- a/Sources/CPegMarkdown/include/pmh_definitions.h +++ /dev/null @@ -1,122 +0,0 @@ -/* PEG Markdown Highlight - * Copyright 2011-2013 Ali Rantakari -- http://hasseg.org - * Licensed under the GPL2+ and MIT licenses (see LICENSE for more info). - * - * pmh_definitions.h - */ - -#ifndef pmh_MARKDOWN_DEFINITIONS -#define pmh_MARKDOWN_DEFINITIONS - -/** \file -* \brief Global definitions for the parser. -*/ - - -/** -* \brief Element types. -* -* The first (documented) ones are language element types. -* -* The last (non-documented) ones are utility types used -* by the parser itself. -* -* \sa pmh_element -*/ -typedef enum -{ - pmh_LINK, /**< Explicit link */ - pmh_AUTO_LINK_URL, /**< Implicit URL link */ - pmh_AUTO_LINK_EMAIL, /**< Implicit email link */ - pmh_IMAGE, /**< Image definition */ - pmh_CODE, /**< Code (inline) */ - pmh_HTML, /**< HTML */ - pmh_HTML_ENTITY, /**< HTML special entity definition */ - pmh_EMPH, /**< Emphasized text */ - pmh_STRONG, /**< Strong text */ - pmh_LIST_BULLET, /**< Bullet for an unordered list item */ - pmh_LIST_ENUMERATOR, /**< Enumerator for an ordered list item */ - pmh_COMMENT, /**< (HTML) Comment */ - - // Code assumes that pmh_H1-6 are in order. - pmh_H1, /**< Header, level 1 */ - pmh_H2, /**< Header, level 2 */ - pmh_H3, /**< Header, level 3 */ - pmh_H4, /**< Header, level 4 */ - pmh_H5, /**< Header, level 5 */ - pmh_H6, /**< Header, level 6 */ - - pmh_BLOCKQUOTE, /**< Blockquote */ - pmh_VERBATIM, /**< Verbatim (e.g. block of code) */ - pmh_HTMLBLOCK, /**< Block of HTML */ - pmh_HRULE, /**< Horizontal rule */ - pmh_REFERENCE, /**< Reference */ - pmh_NOTE, /**< Note */ - - // Utility types used by the parser itself: - - // List of pmh_RAW element lists, each to be processed separately from - // others (for each element in linked lists of this type, `children` points - // to a linked list of pmh_RAW elements): - pmh_RAW_LIST, /**< Internal to parser. Please ignore. */ - - // Span marker for positions in original input to be post-processed - // in a second parsing step: - pmh_RAW, /**< Internal to parser. Please ignore. */ - - // Additional text to be parsed along with spans in the original input - // (these may be added to linked lists of pmh_RAW elements): - pmh_EXTRA_TEXT, /**< Internal to parser. Please ignore. */ - - // Separates linked lists of pmh_RAW elements into parts to be processed - // separate from each other: - pmh_SEPARATOR, /**< Internal to parser. Please ignore. */ - - // Placeholder element used while parsing: - pmh_NO_TYPE, /**< Internal to parser. Please ignore. */ - - // Linked list of *all* elements created while parsing: - pmh_ALL /**< Internal to parser. Please ignore. */ -} pmh_element_type; - -/** -* \brief Number of types in pmh_element_type. -* \sa pmh_element_type -*/ -#define pmh_NUM_TYPES 30 - -/** -* \brief Number of *language element* types in pmh_element_type. -* \sa pmh_element_type -*/ -#define pmh_NUM_LANG_TYPES (pmh_NUM_TYPES - 6) - - -/** -* \brief A Language element occurrence. -*/ -struct pmh_Element -{ - pmh_element_type type; /**< \brief Type of element */ - unsigned long pos; /**< \brief Unicode code point offset marking the - beginning of this element in the - input. */ - unsigned long end; /**< \brief Unicode code point offset marking the - end of this element in the input. */ - struct pmh_Element *next; /**< \brief Next element in list */ - char *label; /**< \brief Label (for links and references) */ - char *address; /**< \brief Address (for links and references) */ -}; -typedef struct pmh_Element pmh_element; - -/** -* \brief Bitfield enumeration of supported Markdown extensions. -*/ -enum pmh_extensions -{ - pmh_EXT_NONE = 0, /**< No extensions */ - pmh_EXT_NOTES = (1 << 0) /**< A footnote syntax like that of Pandoc or - PHP Markdown Extra */ -}; - -#endif diff --git a/Sources/CPegMarkdown/include/pmh_parser.h b/Sources/CPegMarkdown/include/pmh_parser.h deleted file mode 100644 index d46655f..0000000 --- a/Sources/CPegMarkdown/include/pmh_parser.h +++ /dev/null @@ -1,89 +0,0 @@ -/* PEG Markdown Highlight - * Copyright 2011-2013 Ali Rantakari -- http://hasseg.org - * Licensed under the GPL2+ and MIT licenses (see LICENSE for more info). - * - * pmh_parser.h - */ - -#pragma GCC diagnostic ignored "-Wunused-parameter" - -/** \file -* \brief Parser public interface. -*/ - -#ifndef __cplusplus -#include -#endif - -#include -#include -#include "pmh_definitions.h" - - -/** -* \brief Parse Markdown text, return elements -* -* Parses the given Markdown text and returns the results as an -* array of linked lists of elements, indexed by type. -* -* \param[in] text The Markdown text to parse for highlighting. -* \param[in] extensions The extensions to use in parsing (a bitfield -* of pmh_extensions values). -* \param[out] out_result A pmh_element array, indexed by type, containing -* the results of the parsing (linked lists of elements). -* You must pass this to pmh_free_elements() when it's -* not needed anymore. -* -* \sa pmh_element_type -*/ -void pmh_markdown_to_elements(char *text, int extensions, - pmh_element **out_result[]); - -/** -* \brief Sort elements in list by start offset. -* -* Sorts the linked lists of elements in the list returned by -* pmh_markdown_to_elements() by their start offsets (pos). -* -* \param[in] element_lists Array of linked lists of elements (output -* from pmh_markdown_to_elements()). -* -* \sa pmh_markdown_to_elements -* \sa pmh_element::pos -*/ -void pmh_sort_elements_by_pos(pmh_element *element_lists[]); - -/** -* \brief Free pmh_element array -* -* Frees an pmh_element array returned by pmh_markdown_to_elements(). -* -* \param[in] elems The pmh_element array resulting from calling -* pmh_markdown_to_elements(). -* -* \sa pmh_markdown_to_elements -*/ -void pmh_free_elements(pmh_element **elems); - -/** -* \brief Get element type name -* -* \param[in] type The type value to get the name for. -* -* \return The name of the given type as a null-terminated string. -* -* \sa pmh_element_type -*/ -char *pmh_element_name_from_type(pmh_element_type type); - -/** -* \brief Get element type from a name -* -* \param[in] name The name of the type. -* -* \return The element type corresponding to the given name. -* -* \sa pmh_element_type -*/ -pmh_element_type pmh_element_type_from_name(char *name); - diff --git a/Sources/CPegMarkdown/include/pmh_styleparser.h b/Sources/CPegMarkdown/include/pmh_styleparser.h deleted file mode 100644 index 8674e04..0000000 --- a/Sources/CPegMarkdown/include/pmh_styleparser.h +++ /dev/null @@ -1,147 +0,0 @@ -/* PEG Markdown Highlight - * Copyright 2011-2013 Ali Rantakari -- http://hasseg.org - * Licensed under the GPL2+ and MIT licenses (see LICENSE for more info). - * - * pmh_styleparser.h - * - * Public interface of a parser for custom syntax highlighting stylesheets. - */ - -/** \file -* \brief Style parser public interface. -*/ - -#include "pmh_definitions.h" -#include - -/** -* \brief Color (ARGB) attribute value. -* -* All values are 0-255. -*/ -typedef struct -{ - int red; /**< Red color component (0-255) */ - int green; /**< Green color component (0-255) */ - int blue; /**< Blue color component (0-255) */ - int alpha; /**< Alpha (opacity) color component (0-255) */ -} pmh_attr_argb_color; - -/** \brief Font style attribute value. */ -typedef struct -{ - bool italic; - bool bold; - bool underlined; -} pmh_attr_font_styles; - -/** \brief Font size attribute value. */ -typedef struct -{ - int size_pt; /**< The font point size */ - bool is_relative; /**< Whether the size is relative (i.e. size_pt points - larger than the default font) */ -} pmh_attr_font_size; - -/** \brief Style attribute types. */ -typedef enum -{ - pmh_attr_type_foreground_color, /**< Foreground color */ - pmh_attr_type_background_color, /**< Background color */ - pmh_attr_type_caret_color, /**< Caret (insertion point) color */ - pmh_attr_type_font_size_pt, /**< Font size (in points) */ - pmh_attr_type_font_family, /**< Font family */ - pmh_attr_type_font_style, /**< Font style */ - pmh_attr_type_other /**< Arbitrary custom attribute */ -} pmh_attr_type; - -/** -* \brief Style attribute value. -* -* Determine which member to access in this union based on the -* 'type' value of the pmh_style_attribute. -* -* \sa pmh_style_attribute -*/ -typedef union -{ - pmh_attr_argb_color *argb_color; /**< ARGB color */ - pmh_attr_font_styles *font_styles; /**< Font styles */ - pmh_attr_font_size *font_size; /**< Font size */ - char *font_family; /**< Font family */ - char *string; /**< Arbitrary custom string value - (use this if the attribute's type - is pmh_attr_type_other) */ -} pmh_attr_value; - -/** \brief Style attribute. */ -typedef struct pmh_style_attribute -{ - pmh_element_type lang_element_type; /**< The Markdown language element this - style applies to */ - pmh_attr_type type; /**< The type of the attribute */ - char *name; /**< The name of the attribute (if type - is pmh_attr_type_other, you can - use this value to determine what - the attribute is) */ - pmh_attr_value *value; /**< The value of the attribute */ - struct pmh_style_attribute *next; /**< Next attribute in linked list */ -} pmh_style_attribute; - -/** \brief Collection of styles. */ -typedef struct -{ - /** Styles that apply to the editor in general */ - pmh_style_attribute *editor_styles; - - /** Styles that apply to the line in the editor where the caret (insertion - point) resides */ - pmh_style_attribute *editor_current_line_styles; - - /** Styles that apply to the range of selected text in the editor */ - pmh_style_attribute *editor_selection_styles; - - /** Styles that apply to specific Markdown language elements */ - pmh_style_attribute **element_styles; -} pmh_style_collection; - - -/** -* \brief Parse stylesheet string, return style collection -* -* \param[in] input The stylesheet string to parse. -* \param[in] error_callback Callback function to be called when errors -* occur during parsing. The first argument -* to the callback function is the error -* message and the second one the line number -* in the original input where the error -* occurred. The last argument will always -* get the value you pass in for the -* error_callback_context argument to this -* function. -* Pass in NULL to suppress error reporting. -* \param[in] error_callback_context Arbitrary context pointer for the error -* callback function; will be passed in as -* the last argument to error_callback. -* -* \return A pmh_style_collection. You must pass this value to -* pmh_free_style_collection() when it's not needed anymore. -*/ -pmh_style_collection *pmh_parse_styles(char *input, - void(*error_callback)(char*,int,void*), - void *error_callback_context); - -/** -* \brief Free a pmh_style_collection. -* -* Frees a pmh_style_collection value returned by pmh_parse_styles(). -* -* \param[in] collection The collection to free. -*/ -void pmh_free_style_collection(pmh_style_collection *collection); - - -char *pmh_attr_name_from_type(pmh_attr_type type); - -pmh_attr_type pmh_attr_type_from_name(char *name); - diff --git a/Sources/CPegMarkdown/pmh_parser.c b/Sources/CPegMarkdown/pmh_parser.c deleted file mode 100644 index 2c35138..0000000 --- a/Sources/CPegMarkdown/pmh_parser.c +++ /dev/null @@ -1,6807 +0,0 @@ -/* A recursive-descent parser generated by greg 0.4.3 */ - -#include -#include -#include -struct _GREG; -#define YYRULECOUNT 227 - -/* PEG Markdown Highlight - * Copyright 2011-2013 Ali Rantakari -- http://hasseg.org - * Licensed under the GPL2+ and MIT licenses (see LICENSE for more info). - * - * pmh_grammar.leg - * - * This is a slightly adapted version of the PEG grammar from John MacFarlane's - * peg-markdown compiler. - */ - -/* PEG Markdown Highlight - * Copyright 2011-2013 Ali Rantakari -- http://hasseg.org - * Licensed under the GPL2+ and MIT licenses (see LICENSE for more info). - * - * pmh_parser_head.c - * - * Code to be inserted into the beginning of the parser code generated - * from the PEG grammar. - */ - -#include "pmh_parser.h" - -#ifndef pmh_DEBUG_OUTPUT -#define pmh_DEBUG_OUTPUT 0 -#endif - -#if pmh_DEBUG_OUTPUT -#define pmh_IF(x) if (x) -#define pmh_PRINTF(x, ...) fprintf(stderr, x, ##__VA_ARGS__) -#define pmh_PUTCHAR(x) putchar(x) -#else -#define pmh_IF(x) -#define pmh_PRINTF(x, ...) -#define pmh_PUTCHAR(x) -#endif - - -char *strdup_or_null(char *s) -{ - return (s == NULL) ? NULL : strdup(s); -} - - -// Alias strdup to _strdup on MSVC: -#ifdef _MSC_VER -#define strdup _strdup -#endif - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunreachable-code" - -// Internal language element occurrence structure, containing -// both public and private members: -struct pmh_RealElement -{ - // "Public" members: - // (these must match what's defined in pmh_definitions.h) - // ----------------------------------------------- - pmh_element_type type; - unsigned long pos; - unsigned long end; - struct pmh_RealElement *next; - char *label; - char *address; - - // "Private" members for use by the parser itself: - // ----------------------------------------------- - - // next element in list of all elements: - struct pmh_RealElement *all_elems_next; - - // offset to text (for elements of type pmh_EXTRA_TEXT, used when the - // parser reads the value of 'text'): - int text_offset; - - // text content (for elements of type pmh_EXTRA_TEXT): - char *text; - - // children of element (for elements of type pmh_RAW_LIST) - struct pmh_RealElement *children; -}; -typedef struct pmh_RealElement pmh_realelement; - - - - -// Parser state data: -typedef struct -{ - /* The original, unmodified UTF-8 input: */ - char *original_input; - - /* The offsets of the bytes we have stripped from original_input: */ - unsigned long *strip_positions; - size_t strip_positions_len; - - /* Buffer of characters to be parsed: */ - char *charbuf; - - /* Linked list of {start, end} offset pairs determining which parts */ - /* of charbuf to actually parse: */ - pmh_realelement *current_elem; - pmh_realelement *elem_head; - - /* Current parsing offset within charbuf: */ - unsigned long offset; - - /* The extensions to use for parsing (bitfield */ - /* of enum pmh_extensions): */ - int extensions; - - /* Array of parsing result elements, indexed by type: */ - pmh_realelement **head_elems; - - /* Whether we are parsing only references: */ - bool parsing_only_references; - - /* List of reference elements: */ - pmh_realelement *references; -} parser_data; - -static parser_data *mk_parser_data(char *original_input, - unsigned long *strip_positions, - size_t strip_positions_len, - char *charbuf, - pmh_realelement *parsing_elems, - unsigned long offset, - int extensions, - pmh_realelement **head_elems, - pmh_realelement *references) -{ - parser_data *p_data = (parser_data *)malloc(sizeof(parser_data)); - p_data->extensions = extensions; - p_data->original_input = original_input; - p_data->strip_positions = strip_positions; - p_data->strip_positions_len = strip_positions_len; - p_data->charbuf = charbuf; - p_data->offset = offset; - p_data->elem_head = p_data->current_elem = parsing_elems; - p_data->references = references; - p_data->parsing_only_references = false; - if (head_elems != NULL) - p_data->head_elems = head_elems; - else { - p_data->head_elems = (pmh_realelement **) - malloc(sizeof(pmh_realelement *) * pmh_NUM_TYPES); - int i; - for (i = 0; i < pmh_NUM_TYPES; i++) - p_data->head_elems[i] = NULL; - } - return p_data; -} - - -// Forward declarations -static void parse_markdown(parser_data *p_data); -static void parse_references(parser_data *p_data); - - - - - -static char **get_element_type_names() -{ - static char **elem_type_names = NULL; - if (elem_type_names == NULL) - { - elem_type_names = (char **)malloc(sizeof(char*) * pmh_NUM_LANG_TYPES); - int i; - for (i = 0; i < pmh_NUM_LANG_TYPES; i++) - elem_type_names[i] = NULL; - elem_type_names[pmh_LINK] = "LINK"; - elem_type_names[pmh_AUTO_LINK_URL] = "AUTO_LINK_URL"; - elem_type_names[pmh_AUTO_LINK_EMAIL] = "AUTO_LINK_EMAIL"; - elem_type_names[pmh_IMAGE] = "IMAGE"; - elem_type_names[pmh_CODE] = "CODE"; - elem_type_names[pmh_HTML] = "HTML"; - elem_type_names[pmh_HTML_ENTITY] = "HTML_ENTITY"; - elem_type_names[pmh_EMPH] = "EMPH"; - elem_type_names[pmh_STRONG] = "STRONG"; - elem_type_names[pmh_LIST_BULLET] = "LIST_BULLET"; - elem_type_names[pmh_LIST_ENUMERATOR] = "LIST_ENUMERATOR"; - elem_type_names[pmh_COMMENT] = "COMMENT"; - elem_type_names[pmh_H1] = "H1"; - elem_type_names[pmh_H2] = "H2"; - elem_type_names[pmh_H3] = "H3"; - elem_type_names[pmh_H4] = "H4"; - elem_type_names[pmh_H5] = "H5"; - elem_type_names[pmh_H6] = "H6"; - elem_type_names[pmh_BLOCKQUOTE] = "BLOCKQUOTE"; - elem_type_names[pmh_VERBATIM] = "VERBATIM"; - elem_type_names[pmh_HTMLBLOCK] = "HTMLBLOCK"; - elem_type_names[pmh_HRULE] = "HRULE"; - elem_type_names[pmh_REFERENCE] = "REFERENCE"; - elem_type_names[pmh_NOTE] = "NOTE"; - } - return elem_type_names; -} - -pmh_element_type pmh_element_type_from_name(char *name) -{ - char **elem_type_names = get_element_type_names(); - - int i; - for (i = 0; i < pmh_NUM_LANG_TYPES; i++) - { - char *i_name = elem_type_names[i]; - if (i_name == NULL) - continue; - if (strcmp(i_name, name) == 0) - return i; - } - - return pmh_NO_TYPE; -} - -char *pmh_element_name_from_type(pmh_element_type type) -{ - char **elem_type_names = get_element_type_names(); - char* ret = elem_type_names[type]; - if (ret == NULL) - return "unknown type"; - return ret; -} - - - - -/* -Remove pmh_RAW elements with zero length; return pointer -to new head. -*/ -static pmh_realelement *remove_zero_length_raw_spans(pmh_realelement *elem) -{ - pmh_realelement *head = elem; - pmh_realelement *parent = NULL; - pmh_realelement *c = head; - while (c != NULL) - { - if (c->type == pmh_RAW && c->pos >= c->end) - { - if (parent != NULL) - parent->next = c->next; - else - head = c->next; - parent = c; - c = c->next; - continue; - } - parent = c; - c = c->next; - } - return head; -} - -#if pmh_DEBUG_OUTPUT -/* -Print null-terminated string s.t. some characters are -represented by their corresponding espace sequences -*/ -static void print_str_literal_escapes(char *str) -{ - char *c = str; - pmh_PRINTF("'"); - while (*c != '\0') - { - if (*c == '\n') pmh_PRINTF("\\n"); - else if (*c == '\t') pmh_PRINTF("\\t"); - else putchar(*c); - c++; - } - pmh_PRINTF("'"); -} -#endif - -#if pmh_DEBUG_OUTPUT -/* -Print elements in a linked list of -pmh_RAW, pmh_SEPARATOR, pmh_EXTRA_TEXT elements -*/ -static void print_raw_spans_inline(pmh_realelement *elem) -{ - pmh_realelement *cur = elem; - while (cur != NULL) - { - if (cur->type == pmh_SEPARATOR) - pmh_PRINTF(" ", cur->pos); - else if (cur->type == pmh_EXTRA_TEXT) { - pmh_PRINTF("{pmh_ETEXT "); - print_str_literal_escapes(cur->text); - pmh_PRINTF("}"); - } - else - pmh_PRINTF("(%ld-%ld) ", cur->pos, cur->end); - cur = cur->next; - } -} -#endif - -/* -Perform postprocessing parsing runs for pmh_RAW_LIST elements in `elem`, -iteratively until no such elements exist. -*/ -static void process_raw_blocks(parser_data *p_data) -{ - pmh_PRINTF("--------process_raw_blocks---------\n"); - while (p_data->head_elems[pmh_RAW_LIST] != NULL) - { - pmh_PRINTF("new iteration.\n"); - pmh_realelement *cursor = p_data->head_elems[pmh_RAW_LIST]; - p_data->head_elems[pmh_RAW_LIST] = NULL; - while (cursor != NULL) - { - pmh_realelement *span_list = (pmh_realelement*)cursor->children; - - span_list = remove_zero_length_raw_spans(span_list); - - #if pmh_DEBUG_OUTPUT - pmh_PRINTF(" process: "); - print_raw_spans_inline(span_list); - pmh_PRINTF("\n"); - #endif - - while (span_list != NULL) - { - pmh_PRINTF("next: span_list: %ld-%ld\n", - span_list->pos, span_list->end); - - // Skip separators in the beginning, as well as - // separators after another separator: - if (span_list->type == pmh_SEPARATOR) { - span_list = span_list->next; - continue; - } - - // Store list of spans until next separator in subspan_list: - pmh_realelement *subspan_list = span_list; - pmh_realelement *previous = NULL; - while (span_list != NULL && span_list->type != pmh_SEPARATOR) { - previous = span_list; - span_list = span_list->next; - } - if (span_list != NULL && span_list->type == pmh_SEPARATOR) { - span_list = span_list->next; - previous->next = NULL; - } - - #if pmh_DEBUG_OUTPUT - pmh_PRINTF(" subspan process: "); - print_raw_spans_inline(subspan_list); - pmh_PRINTF("\n"); - #endif - - // Process subspan_list: - parser_data *raw_p_data = mk_parser_data( - p_data->original_input, - p_data->strip_positions, - p_data->strip_positions_len, - p_data->charbuf, - subspan_list, - subspan_list->pos, - p_data->extensions, - p_data->head_elems, - p_data->references - ); - parse_markdown(raw_p_data); - free(raw_p_data); - - pmh_PRINTF("parse over\n"); - } - - cursor = cursor->next; - } - } -} - - -#if pmh_DEBUG_OUTPUT -static void print_raw_blocks(char *text, pmh_realelement *elem[]) -{ - pmh_PRINTF("--------print_raw_blocks---------\n"); - pmh_PRINTF("block:\n"); - pmh_realelement *cursor = elem[pmh_RAW_LIST]; - while (cursor != NULL) - { - print_raw_spans_inline(cursor->children); - cursor = cursor->next; - } -} -#endif - - - - -/* Free all elements created while parsing */ -void pmh_free_elements(pmh_element **elems) -{ - pmh_realelement *cursor = (pmh_realelement*)elems[pmh_ALL]; - while (cursor != NULL) { - pmh_realelement *tofree = cursor; - cursor = cursor->all_elems_next; - if (tofree->text != NULL) - free(tofree->text); - if (tofree->label != NULL) - free(tofree->label); - if (tofree->address != NULL) - free(tofree->address); - free(tofree); - } - elems[pmh_ALL] = NULL; - - free(elems); -} - - - - - - -#define IS_CONTINUATION_BYTE(x) ((x & 0xC0) == 0x80) -#define HAS_UTF8_BOM(x) ( ((*x & 0xFF) == 0xEF)\ - && ((*(x+1) & 0xFF) == 0xBB)\ - && ((*(x+2) & 0xFF) == 0xBF) ) -#define ADD_STRIP_POS(x) \ - /* reallocate more space for the array, if needed: */ \ - if (strip_positions_size <= strip_positions_pos) { \ - size_t new_size = strip_positions_size * 2; \ - unsigned long *new_arr = (unsigned long *) \ - calloc(new_size, \ - sizeof(unsigned long)); \ - memcpy(new_arr, strip_positions, \ - (sizeof(unsigned long) * strip_positions_size)); \ - strip_positions_size = new_size; \ - free(strip_positions); \ - strip_positions = new_arr; \ - } \ - strip_positions[strip_positions_pos] = x; \ - strip_positions_pos++; - -/* -Copy `str` to `out`, while doing the following: - - remove UTF-8 continuation bytes - - remove possible UTF-8 BOM (byte order mark) - - append two newlines to the end (like peg-markdown does) - - keep track of which bytes we have stripped (in strip_positions) -*/ -static int strcpy_preformat(char *str, char **out, - unsigned long **out_strip_positions, - size_t *out_strip_positions_len) -{ - size_t strip_positions_size = 1024; - size_t strip_positions_pos = 0; - unsigned long *strip_positions = (unsigned long *) - calloc(strip_positions_size, - sizeof(unsigned long)); - - - // +2 in the following is due to the "\n\n" suffix: - char *new_str = (char *)malloc(sizeof(char) * strlen(str) + 1 + 2); - char *c = str; - int i = 0; - - if (HAS_UTF8_BOM(c)) { - c += 3; - ADD_STRIP_POS(0); - ADD_STRIP_POS(1); - ADD_STRIP_POS(2); - } - - while (*c != '\0') - { - if (!IS_CONTINUATION_BYTE(*c)) { - *(new_str+i) = *c, i++; - } else { - ADD_STRIP_POS((int)(c-str)); - } - c++; - } - - *(new_str+(i++)) = '\n'; - *(new_str+(i++)) = '\n'; - *(new_str+i) = '\0'; - - *out = new_str; - *out_strip_positions = strip_positions; - *out_strip_positions_len = strip_positions_pos; - return i; -} - - - -void pmh_markdown_to_elements(char *text, int extensions, - pmh_element **out_result[]) -{ - char *text_copy = NULL; - unsigned long *strip_positions = NULL; - size_t strip_positions_len = 0; - int text_copy_len = strcpy_preformat(text, &text_copy, &strip_positions, - &strip_positions_len); - - pmh_realelement *parsing_elem = (pmh_realelement *) - malloc(sizeof(pmh_realelement)); - parsing_elem->type = pmh_RAW; - parsing_elem->pos = 0; - parsing_elem->end = text_copy_len; - parsing_elem->next = NULL; - - parser_data *p_data = mk_parser_data( - text, - strip_positions, - strip_positions_len, - text_copy, - parsing_elem, - 0, - extensions, - NULL, - NULL - ); - pmh_realelement **result = p_data->head_elems; - - if (*text_copy != '\0') - { - // Get reference definitions into p_data->references - parse_references(p_data); - - // Reset parser state to beginning of input - p_data->offset = 0; - p_data->current_elem = p_data->elem_head; - - // Parse whole document - parse_markdown(p_data); - - #if pmh_DEBUG_OUTPUT - print_raw_blocks(text_copy, result); - #endif - - process_raw_blocks(p_data); - } - - free(strip_positions); - free(p_data); - free(parsing_elem); - free(text_copy); - - *out_result = (pmh_element**)result; -} - - - -/* -Mergesort linked list of elements (using comparison function `compare`), -return new head. (Adapted slightly from Simon Tatham's algorithm.) -*/ -static pmh_element *ll_mergesort(pmh_element *list, - int (*compare)(const pmh_element*, - const pmh_element*)) -{ - if (!list) - return NULL; - - pmh_element *out_head = list; - - /* Merge widths of doubling size until done */ - int merge_width = 1; - while (1) - { - pmh_element *l, *r; /* left & right segment pointers */ - pmh_element *tail = NULL; /* tail of sorted section */ - - l = out_head; - out_head = NULL; - - int merge_count = 0; - - while (l) - { - merge_count++; - - /* Position r, determine lsize & rsize */ - r = l; - int lsize = 0; - int i; - for (i = 0; i < merge_width; i++) { - lsize++; - r = r->next; - if (!r) - break; - } - int rsize = merge_width; - - /* Merge l & r */ - while (lsize > 0 || (rsize > 0 && r)) - { - bool get_from_left = false; - if (lsize == 0) get_from_left = false; - else if (rsize == 0 || !r) get_from_left = true; - else if (compare(l,r) <= 0) get_from_left = true; - - pmh_element *e; - if (get_from_left) { - e = l; l = l->next; lsize--; - } else { - e = r; r = r->next; rsize--; - } - - /* add the next pmh_element to the merged list */ - if (tail) - tail->next = e; - else - out_head = e; - tail = e; - } - - l = r; - } - tail->next = NULL; - - if (merge_count <= 1) - return out_head; - - merge_width *= 2; - } -} - -static int elem_compare_by_pos(const pmh_element *a, const pmh_element *b) -{ - return a->pos - b->pos; -} - -void pmh_sort_elements_by_pos(pmh_element *element_lists[]) -{ - int i; - for (i = 0; i < pmh_NUM_LANG_TYPES; i++) - element_lists[i] = ll_mergesort(element_lists[i], &elem_compare_by_pos); -} - - - - - - - - -/* return true if extension is selected */ -static bool extension(parser_data *p_data, int ext) -{ - return ((p_data->extensions & ext) != 0); -} - -/* return reference pmh_realelement for a given label */ -static pmh_realelement *get_reference(parser_data *p_data, char *label) -{ - if (!label) - return NULL; - - pmh_realelement *cursor = p_data->references; - while (cursor != NULL) - { - if (cursor->label && strcmp(label, cursor->label) == 0) - return cursor; - cursor = cursor->next; - } - return NULL; -} - - -/* cons an element/list onto a list, returning pointer to new head */ -static pmh_realelement *cons(pmh_realelement *elem, pmh_realelement *list) -{ - assert(elem != NULL); - - pmh_realelement *cur = elem; - while (cur->next != NULL) { - cur = cur->next; - } - cur->next = list; - - return elem; -} - - -/* reverse a list, returning pointer to new list */ -static pmh_realelement *reverse(pmh_realelement *list) -{ - pmh_realelement *new_head = NULL; - pmh_realelement *next = NULL; - while (list != NULL) { - next = list->next; - list->next = new_head; - new_head = list; - list = next; - } - return new_head; -} - - - -/* construct pmh_realelement */ -static pmh_realelement *mk_element(parser_data *p_data, pmh_element_type type, - long pos, long end) -{ - pmh_realelement *result = (pmh_realelement *)malloc(sizeof(pmh_realelement)); - result->type = type; - result->pos = pos; - result->end = end; - result->next = NULL; - result->text_offset = 0; - result->label = result->address = result->text = NULL; - - pmh_realelement *old_all_elements_head = p_data->head_elems[pmh_ALL]; - p_data->head_elems[pmh_ALL] = result; - result->all_elems_next = old_all_elements_head; - - //pmh_PRINTF(" mk_element: %s [%ld - %ld]\n", pmh_element_name_from_type(type), pos, end); - - return result; -} - -static pmh_realelement *copy_element(parser_data *p_data, pmh_realelement *elem) -{ - pmh_realelement *result = mk_element(p_data, elem->type, elem->pos, elem->end); - result->label = strdup_or_null(elem->label); - result->text = strdup_or_null(elem->text); - result->address = strdup_or_null(elem->address); - return result; -} - -/* construct pmh_EXTRA_TEXT pmh_realelement */ -static pmh_realelement *mk_etext(parser_data *p_data, char *string) -{ - pmh_realelement *result; - assert(string != NULL); - result = mk_element(p_data, pmh_EXTRA_TEXT, 0,0); - result->text = strdup_or_null(string); - return result; -} - - -/* -Given an element where the offsets {pos, end} represent -locations in the *parsed text* (defined by the linked list of pmh_RAW and -pmh_EXTRA_TEXT elements in p_data->current_elem), fix these offsets to represent -corresponding offsets in the parse buffer (p_data->charbuf). Also split -the given pmh_realelement into multiple parts if its offsets span multiple -p_data->current_elem elements. Return the (list of) elements with real offsets. -*/ -static pmh_realelement *fix_offsets(parser_data *p_data, pmh_realelement *elem) -{ - if (elem->type == pmh_EXTRA_TEXT) - return mk_etext(p_data, elem->text); - - pmh_realelement *new_head = copy_element(p_data, elem); - - pmh_realelement *tail = new_head; - pmh_realelement *prev = NULL; - - bool found_start = false; - bool found_end = false; - bool tail_needs_pos = false; - unsigned long previous_end = 0; - unsigned long c = 0; - - pmh_realelement *cursor = p_data->elem_head; - while (cursor != NULL) - { - int thislen = (cursor->type == pmh_EXTRA_TEXT) - ? strlen(cursor->text) - : cursor->end - cursor->pos; - - if (tail_needs_pos && cursor->type != pmh_EXTRA_TEXT) { - tail->pos = cursor->pos; - tail_needs_pos = false; - } - - unsigned int this_pos = cursor->pos; - - if (!found_start && (c <= elem->pos && elem->pos <= c+thislen)) { - tail->pos = (cursor->type == pmh_EXTRA_TEXT) - ? previous_end - : cursor->pos + (elem->pos - c); - this_pos = tail->pos; - found_start = true; - } - - if (!found_end && (c <= elem->end && elem->end <= c+thislen)) { - tail->end = (cursor->type == pmh_EXTRA_TEXT) - ? previous_end - : cursor->pos + (elem->end - c); - found_end = true; - } - - if (found_start && found_end) - break; - - if (cursor->type != pmh_EXTRA_TEXT) - previous_end = cursor->end; - - if (found_start) { - pmh_realelement *new_elem = copy_element(p_data, tail); - new_elem->pos = this_pos; - new_elem->end = cursor->end; - new_elem->next = tail; - if (prev != NULL) - prev->next = new_elem; - if (new_head == tail) - new_head = new_elem; - prev = new_elem; - tail_needs_pos = true; - } - - c += thislen; - cursor = cursor->next; - } - - return new_head; -} - - - -/* Add an element to p_data->head_elems. */ -static void add(parser_data *p_data, pmh_realelement *elem) -{ - if (elem->type != pmh_RAW_LIST) - { - pmh_PRINTF(" add: %s [%ld - %ld]\n", - pmh_element_name_from_type(elem->type), elem->pos, elem->end); - elem = fix_offsets(p_data, elem); - pmh_PRINTF(" > %s [%ld - %ld]\n", - pmh_element_name_from_type(elem->type), elem->pos, elem->end); - } - else - { - pmh_PRINTF(" add: pmh_RAW_LIST "); - pmh_realelement *cursor = elem->children; - pmh_realelement *previous = NULL; - while (cursor != NULL) - { - pmh_realelement *next = cursor->next; - pmh_PRINTF("(%ld-%ld)>", cursor->pos, cursor->end); - pmh_realelement *new_cursor = fix_offsets(p_data, cursor); - if (previous != NULL) - previous->next = new_cursor; - else - elem->children = new_cursor; - pmh_PRINTF("(%ld-%ld)", new_cursor->pos, new_cursor->end); - while (new_cursor->next != NULL) { - new_cursor = new_cursor->next; - pmh_PRINTF("(%ld-%ld)", new_cursor->pos, new_cursor->end); - } - pmh_PRINTF(" "); - if (next != NULL) - new_cursor->next = next; - previous = new_cursor; - cursor = next; - } - pmh_PRINTF("\n"); - } - - if (p_data->head_elems[elem->type] == NULL) - p_data->head_elems[elem->type] = elem; - else - { - pmh_realelement *last = elem; - while (last->next != NULL) - last = last->next; - last->next = p_data->head_elems[elem->type]; - p_data->head_elems[elem->type] = elem; - } -} - - -// Given a range in the list of spans we use for parsing (pos, end), return -// a copy of the corresponding section in the original input, with all of -// the UTF-8 bytes intact: -static char *copy_input_span(parser_data *p_data, - unsigned long pos, unsigned long end) -{ - if (end <= pos) - return NULL; - - char *ret = NULL; - - // Adjust (pos,end) to match actual indexes in charbuf: - pmh_realelement *dummy = mk_element(p_data, pmh_NO_TYPE, pos, end); - pmh_realelement *fixed_dummies = fix_offsets(p_data, dummy); - pmh_realelement *cursor = fixed_dummies; - while (cursor != NULL) - { - if (cursor->end <= cursor->pos) - { - cursor = cursor->next; - continue; - } - - // Adjust cursor's span to take bytes stripped from the original - // input into account (i.e. match the corresponding span in - // p_data->original_input): - unsigned long adjusted_pos = cursor->pos; - unsigned long adjusted_end = cursor->end; - size_t i; - for (i = 0; i < p_data->strip_positions_len; i++) - { - unsigned long strip_position = p_data->strip_positions[i]; - if (strip_position <= adjusted_pos) - adjusted_pos++; - if (strip_position <= adjusted_end) - adjusted_end++; - else - break; - } - - // Copy span from original input: - size_t adjusted_len = adjusted_end - adjusted_pos; - char *str = (char *)malloc(sizeof(char)*adjusted_len + 1); - *str = '\0'; - strncat(str, (p_data->original_input + adjusted_pos), adjusted_len); - - if (ret == NULL) - ret = str; - else - { - // append str to ret: - char *new_ret = (char *)malloc(sizeof(char) - *(strlen(str) + strlen(ret)) + 1); - *new_ret = '\0'; - strcat(new_ret, ret); - strcat(new_ret, str); - free(ret); - free(str); - ret = new_ret; - } - - cursor = cursor->next; - } - - return ret; -} - - - - - -# define YYSTYPE pmh_realelement * -#ifdef __DEBUG__ -# define YY_DEBUG 1 -#endif - -#define YY_INPUT(buf, result, max_size)\ - yy_input_func(buf, &result, max_size, (parser_data *)G->data) - -static void yy_input_func(char *buf, int *result, int max_size, - parser_data *p_data) -{ - if (p_data->current_elem == NULL) - { - (*result) = 0; - return; - } - - if (p_data->current_elem->type == pmh_EXTRA_TEXT) - { - int yyc; - bool moreToRead = (p_data->current_elem->text - && *(p_data->current_elem->text - + p_data->current_elem->text_offset) != '\0'); - if (moreToRead) - { - yyc = *(p_data->current_elem->text + p_data->current_elem->text_offset++); - pmh_PRINTF("\e[47;30m"); pmh_PUTCHAR(yyc); pmh_PRINTF("\e[0m"); - pmh_IF(yyc == '\n') pmh_PRINTF("\e[47m \e[0m"); - } - else - { - yyc = EOF; - p_data->current_elem = p_data->current_elem->next; - pmh_PRINTF("\e[41m \e[0m"); - if (p_data->current_elem != NULL) - p_data->offset = p_data->current_elem->pos; - } - (*result) = (EOF == yyc) ? 0 : (*(buf) = yyc, 1); - return; - } - - *(buf) = *(p_data->charbuf + p_data->offset); - (*result) = (*buf != '\0'); - p_data->offset++; - - pmh_PRINTF("\e[43;30m"); pmh_PUTCHAR(*buf); pmh_PRINTF("\e[0m"); - pmh_IF(*buf == '\n') pmh_PRINTF("\e[42m \e[0m"); - - if (p_data->offset >= p_data->current_elem->end) - { - p_data->current_elem = p_data->current_elem->next; - pmh_PRINTF("\e[41m \e[0m"); - if (p_data->current_elem != NULL) - p_data->offset = p_data->current_elem->pos; - } -} - - - -#define elem(x) mk_element((parser_data *)G->data, x, thunk->begin, thunk->end) -#define elem_s(x) mk_element((parser_data *)G->data, x, s->pos, thunk->end) -#define mk_sep mk_element((parser_data *)G->data, pmh_SEPARATOR, 0,0) -#define mk_notype mk_element((parser_data *)G->data, pmh_NO_TYPE, 0,0) -#define etext(x) mk_etext((parser_data *)G->data, x) -#define ADD(x) add((parser_data *)G->data, x) -#define EXT(x) extension((parser_data *)G->data, x) -#define REF_EXISTS(x) reference_exists((parser_data *)G->data, x) -#define GET_REF(x) get_reference((parser_data *)G->data, x) -#define PARSING_REFERENCES ((parser_data *)G->data)->parsing_only_references -#define FREE_LABEL(l) { free(l->label); l->label = NULL; } -#define FREE_ADDRESS(l) { free(l->address); l->address = NULL; } - -// This gives us the text matched with < > as it appears in the original input: -#define COPY_YYTEXT_ORIG() copy_input_span((parser_data *)G->data, thunk->begin, thunk->end) - - -#ifndef YY_ALLOC -#define YY_ALLOC(N, D) malloc(N) -#endif -#ifndef YY_CALLOC -#define YY_CALLOC(N, S, D) calloc(N, S) -#endif -#ifndef YY_REALLOC -#define YY_REALLOC(B, N, D) realloc(B, N) -#endif -#ifndef YY_FREE -#define YY_FREE free -#endif -#ifndef YY_LOCAL -#define YY_LOCAL(T) static T -#endif -#ifndef YY_ACTION -#define YY_ACTION(T) static T -#endif -#ifndef YY_RULE -#define YY_RULE(T) static T -#endif -#ifndef YY_PARSE -#define YY_PARSE(T) T -#endif -#ifndef YY_NAME -#define YY_NAME(N) yy##N -#endif -#ifndef YY_INPUT -#define YY_INPUT(buf, result, max_size) \ - { \ - int yyc= getchar(); \ - result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \ - yyprintf((stderr, "<%c>", yyc)); \ - } -#endif -#ifndef YY_BEGIN -#define YY_BEGIN ( G->begin= G->pos, 1) -#endif -#ifndef YY_END -#define YY_END ( G->end= G->pos, 1) -#endif -#ifdef YY_DEBUG -# define yyprintf(args) fprintf args -#else -# define yyprintf(args) -#endif -#ifndef YYSTYPE -#define YYSTYPE int -#endif -#ifndef YY_XTYPE -#define YY_XTYPE void * -#endif -#ifndef YY_XVAR -#define YY_XVAR yyxvar -#endif - -#ifndef YY_STACK_SIZE -#define YY_STACK_SIZE 128 -#endif - -#ifndef YY_BUFFER_START_SIZE -#define YY_BUFFER_START_SIZE 1024 -#endif - -#ifndef YY_PART -#define yydata G->data -#define yy G->ss - -struct _yythunk; // forward declaration -typedef void (*yyaction)(struct _GREG *G, char *yytext, int yyleng, struct _yythunk *thunkpos, YY_XTYPE YY_XVAR); -typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk; - -typedef struct _GREG { - char *buf; - int buflen; - int offset; - int pos; - int limit; - char *text; - int textlen; - int begin; - int end; - yythunk *thunks; - int thunkslen; - int thunkpos; - YYSTYPE ss; - YYSTYPE *val; - YYSTYPE *vals; - int valslen; - YY_XTYPE data; -} GREG; - -YY_LOCAL(int) yyrefill(GREG *G) -{ - int yyn; - while (G->buflen - G->pos < 512) - { - G->buflen *= 2; - G->buf= (char *)YY_REALLOC(G->buf, G->buflen, G->data); - } - YY_INPUT((G->buf + G->pos), yyn, (G->buflen - G->pos)); - if (!yyn) return 0; - G->limit += yyn; - return 1; -} - -YY_LOCAL(int) yymatchDot(GREG *G) -{ - if (G->pos >= G->limit && !yyrefill(G)) return 0; - ++G->pos; - return 1; -} - -YY_LOCAL(int) yymatchChar(GREG *G, int c) -{ - if (G->pos >= G->limit && !yyrefill(G)) return 0; - if ((unsigned char)G->buf[G->pos] == c) - { - ++G->pos; - yyprintf((stderr, " ok yymatchChar(%c) @ %s\n", c, G->buf+G->pos)); - return 1; - } - yyprintf((stderr, " fail yymatchChar(%c) @ %s\n", c, G->buf+G->pos)); - return 0; -} - -YY_LOCAL(int) yymatchString(GREG *G, char *s) -{ - int yysav= G->pos; - while (*s) - { - if (G->pos >= G->limit && !yyrefill(G)) return 0; - if (G->buf[G->pos] != *s) - { - G->pos= yysav; - return 0; - } - ++s; - ++G->pos; - } - return 1; -} - -YY_LOCAL(int) yymatchClass(GREG *G, unsigned char *bits) -{ - int c; - if (G->pos >= G->limit && !yyrefill(G)) return 0; - c= (unsigned char)G->buf[G->pos]; - if (bits[c >> 3] & (1 << (c & 7))) - { - ++G->pos; - yyprintf((stderr, " ok yymatchClass @ %s\n", G->buf+G->pos)); - return 1; - } - yyprintf((stderr, " fail yymatchClass @ %s\n", G->buf+G->pos)); - return 0; -} - -YY_LOCAL(void) yyDo(GREG *G, yyaction action, int begin, int end) -{ - while (G->thunkpos >= G->thunkslen) - { - G->thunkslen *= 2; - G->thunks= (yythunk *)YY_REALLOC(G->thunks, sizeof(yythunk) * G->thunkslen, G->data); - } - G->thunks[G->thunkpos].begin= begin; - G->thunks[G->thunkpos].end= end; - G->thunks[G->thunkpos].action= action; - ++G->thunkpos; -} - -YY_LOCAL(int) yyText(GREG *G, int begin, int end) -{ - int yyleng= end - begin; - if (yyleng <= 0) - yyleng= 0; - else - { - while (G->textlen < (yyleng + 1)) - { - G->textlen *= 2; - G->text= (char *)YY_REALLOC(G->text, G->textlen, G->data); - } - memcpy(G->text, G->buf + begin, yyleng); - } - G->text[yyleng]= '\0'; - return yyleng; -} - -YY_LOCAL(void) yyDone(GREG *G) -{ - int pos; - for (pos= 0; pos < G->thunkpos; ++pos) - { - yythunk *thunk= &G->thunks[pos]; - int yyleng= thunk->end ? yyText(G, thunk->begin, thunk->end) : thunk->begin; - yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, G->text)); - thunk->action(G, G->text, yyleng, thunk, G->data); - } - G->thunkpos= 0; -} - -YY_LOCAL(void) yyCommit(GREG *G) -{ - if ((G->limit -= G->pos)) - { - memmove(G->buf, G->buf + G->pos, G->limit); - } - G->offset += G->pos; - G->begin -= G->pos; - G->end -= G->pos; - G->pos= G->thunkpos= 0; -} - -YY_LOCAL(int) yyAccept(GREG *G, int tp0) -{ - if (tp0) - { - fprintf(stderr, "accept denied at %d\n", tp0); - return 0; - } - else - { - yyDone(G); - yyCommit(G); - } - return 1; -} - -YY_LOCAL(void) yyPush(GREG *G, char *text, int count, yythunk *thunk, YY_XTYPE YY_XVAR) { G->val += count; } -YY_LOCAL(void) yyPop(GREG *G, char *text, int count, yythunk *thunk, YY_XTYPE YY_XVAR) { G->val -= count; } -YY_LOCAL(void) yySet(GREG *G, char *text, int count, yythunk *thunk, YY_XTYPE YY_XVAR) { G->val[count]= G->ss; } - -#endif /* YY_PART */ - -#define YYACCEPT yyAccept(G, yythunkpos0) - -YY_RULE(int) yy_Dollar2Math(GREG *G); /* 227 */ -YY_RULE(int) yy_Dollar1Math(GREG *G); /* 226 */ -YY_RULE(int) yy_RawNoteBlock(GREG *G); /* 225 */ -YY_RULE(int) yy_RawNoteReference(GREG *G); /* 224 */ -YY_RULE(int) yy_ExtendedSpecialChar(GREG *G); /* 223 */ -YY_RULE(int) yy_AlphanumericAscii(GREG *G); /* 222 */ -YY_RULE(int) yy_Quoted(GREG *G); /* 221 */ -YY_RULE(int) yy_HtmlTag(GREG *G); /* 220 */ -YY_RULE(int) yy_Waves5(GREG *G); /* 219 */ -YY_RULE(int) yy_Waves4(GREG *G); /* 218 */ -YY_RULE(int) yy_Waves3(GREG *G); /* 217 */ -YY_RULE(int) yy_Ticks5(GREG *G); /* 216 */ -YY_RULE(int) yy_Ticks4(GREG *G); /* 215 */ -YY_RULE(int) yy_Ticks3(GREG *G); /* 214 */ -YY_RULE(int) yy_Ticks2(GREG *G); /* 213 */ -YY_RULE(int) yy_Ticks1(GREG *G); /* 212 */ -YY_RULE(int) yy_SkipBlock(GREG *G); /* 211 */ -YY_RULE(int) yy_References(GREG *G); /* 210 */ -YY_RULE(int) yy_EmptyTitle(GREG *G); /* 209 */ -YY_RULE(int) yy_RefTitleParens(GREG *G); /* 208 */ -YY_RULE(int) yy_RefTitleDouble(GREG *G); /* 207 */ -YY_RULE(int) yy_RefTitleSingle(GREG *G); /* 206 */ -YY_RULE(int) yy_RefTitle(GREG *G); /* 205 */ -YY_RULE(int) yy_RefSrc(GREG *G); /* 204 */ -YY_RULE(int) yy_AutoLinkEmail(GREG *G); /* 203 */ -YY_RULE(int) yy_AutoLinkUrl(GREG *G); /* 202 */ -YY_RULE(int) yy_TitleDouble(GREG *G); /* 201 */ -YY_RULE(int) yy_TitleSingle(GREG *G); /* 200 */ -YY_RULE(int) yy_Nonspacechar(GREG *G); /* 199 */ -YY_RULE(int) yy_SourceContents(GREG *G); /* 198 */ -YY_RULE(int) yy_Title(GREG *G); /* 197 */ -YY_RULE(int) yy_Source(GREG *G); /* 196 */ -YY_RULE(int) yy_Label(GREG *G); /* 195 */ -YY_RULE(int) yy_ReferenceLinkSingle(GREG *G); /* 194 */ -YY_RULE(int) yy_ReferenceLinkDouble(GREG *G); /* 193 */ -YY_RULE(int) yy_AutoLink(GREG *G); /* 192 */ -YY_RULE(int) yy_ReferenceLink(GREG *G); /* 191 */ -YY_RULE(int) yy_ExplicitLink(GREG *G); /* 190 */ -YY_RULE(int) yy_StrongUl(GREG *G); /* 189 */ -YY_RULE(int) yy_StrongStar(GREG *G); /* 188 */ -YY_RULE(int) yy_Whitespace(GREG *G); /* 187 */ -YY_RULE(int) yy_EmphUl(GREG *G); /* 186 */ -YY_RULE(int) yy_EmphStar(GREG *G); /* 185 */ -YY_RULE(int) yy_StarLine(GREG *G); /* 184 */ -YY_RULE(int) yy_UlLine(GREG *G); /* 183 */ -YY_RULE(int) yy_SpecialChar(GREG *G); /* 182 */ -YY_RULE(int) yy_Eof(GREG *G); /* 181 */ -YY_RULE(int) yy_NormalEndline(GREG *G); /* 180 */ -YY_RULE(int) yy_TerminalEndline(GREG *G); /* 179 */ -YY_RULE(int) yy_LineBreak(GREG *G); /* 178 */ -YY_RULE(int) yy_CharEntity(GREG *G); /* 177 */ -YY_RULE(int) yy_DecEntity(GREG *G); /* 176 */ -YY_RULE(int) yy_HexEntity(GREG *G); /* 175 */ -YY_RULE(int) yy_Alphanumeric(GREG *G); /* 174 */ -YY_RULE(int) yy_NormalChar(GREG *G); /* 173 */ -YY_RULE(int) yy_Symbol(GREG *G); /* 172 */ -YY_RULE(int) yy_EscapedChar(GREG *G); /* 171 */ -YY_RULE(int) yy_Entity(GREG *G); /* 170 */ -YY_RULE(int) yy_RawHtml(GREG *G); /* 169 */ -YY_RULE(int) yy_Code(GREG *G); /* 168 */ -YY_RULE(int) yy_InlineNote(GREG *G); /* 167 */ -YY_RULE(int) yy_NoteReference(GREG *G); /* 166 */ -YY_RULE(int) yy_Link(GREG *G); /* 165 */ -YY_RULE(int) yy_Image(GREG *G); /* 164 */ -YY_RULE(int) yy_Emph(GREG *G); /* 163 */ -YY_RULE(int) yy_Strong(GREG *G); /* 162 */ -YY_RULE(int) yy_Math(GREG *G); /* 161 */ -YY_RULE(int) yy_Space(GREG *G); /* 160 */ -YY_RULE(int) yy_UlOrStarLine(GREG *G); /* 159 */ -YY_RULE(int) yy_Str(GREG *G); /* 158 */ -YY_RULE(int) yy_InStyleTags(GREG *G); /* 157 */ -YY_RULE(int) yy_StyleClose(GREG *G); /* 156 */ -YY_RULE(int) yy_StyleOpen(GREG *G); /* 155 */ -YY_RULE(int) yy_HtmlBlockType(GREG *G); /* 154 */ -YY_RULE(int) yy_HtmlBlockSelfClosing(GREG *G); /* 153 */ -YY_RULE(int) yy_HtmlComment(GREG *G); /* 152 */ -YY_RULE(int) yy_HtmlBlockInTags(GREG *G); /* 151 */ -YY_RULE(int) yy_HtmlBlockScript(GREG *G); /* 150 */ -YY_RULE(int) yy_HtmlBlockCloseScript(GREG *G); /* 149 */ -YY_RULE(int) yy_HtmlBlockOpenScript(GREG *G); /* 148 */ -YY_RULE(int) yy_HtmlBlockTr(GREG *G); /* 147 */ -YY_RULE(int) yy_HtmlBlockCloseTr(GREG *G); /* 146 */ -YY_RULE(int) yy_HtmlBlockOpenTr(GREG *G); /* 145 */ -YY_RULE(int) yy_HtmlBlockThead(GREG *G); /* 144 */ -YY_RULE(int) yy_HtmlBlockCloseThead(GREG *G); /* 143 */ -YY_RULE(int) yy_HtmlBlockOpenThead(GREG *G); /* 142 */ -YY_RULE(int) yy_HtmlBlockTh(GREG *G); /* 141 */ -YY_RULE(int) yy_HtmlBlockCloseTh(GREG *G); /* 140 */ -YY_RULE(int) yy_HtmlBlockOpenTh(GREG *G); /* 139 */ -YY_RULE(int) yy_HtmlBlockTfoot(GREG *G); /* 138 */ -YY_RULE(int) yy_HtmlBlockCloseTfoot(GREG *G); /* 137 */ -YY_RULE(int) yy_HtmlBlockOpenTfoot(GREG *G); /* 136 */ -YY_RULE(int) yy_HtmlBlockTd(GREG *G); /* 135 */ -YY_RULE(int) yy_HtmlBlockCloseTd(GREG *G); /* 134 */ -YY_RULE(int) yy_HtmlBlockOpenTd(GREG *G); /* 133 */ -YY_RULE(int) yy_HtmlBlockTbody(GREG *G); /* 132 */ -YY_RULE(int) yy_HtmlBlockCloseTbody(GREG *G); /* 131 */ -YY_RULE(int) yy_HtmlBlockOpenTbody(GREG *G); /* 130 */ -YY_RULE(int) yy_HtmlBlockLi(GREG *G); /* 129 */ -YY_RULE(int) yy_HtmlBlockCloseLi(GREG *G); /* 128 */ -YY_RULE(int) yy_HtmlBlockOpenLi(GREG *G); /* 127 */ -YY_RULE(int) yy_HtmlBlockFrameset(GREG *G); /* 126 */ -YY_RULE(int) yy_HtmlBlockCloseFrameset(GREG *G); /* 125 */ -YY_RULE(int) yy_HtmlBlockOpenFrameset(GREG *G); /* 124 */ -YY_RULE(int) yy_HtmlBlockDt(GREG *G); /* 123 */ -YY_RULE(int) yy_HtmlBlockCloseDt(GREG *G); /* 122 */ -YY_RULE(int) yy_HtmlBlockOpenDt(GREG *G); /* 121 */ -YY_RULE(int) yy_HtmlBlockDd(GREG *G); /* 120 */ -YY_RULE(int) yy_HtmlBlockCloseDd(GREG *G); /* 119 */ -YY_RULE(int) yy_HtmlBlockOpenDd(GREG *G); /* 118 */ -YY_RULE(int) yy_HtmlBlockUl(GREG *G); /* 117 */ -YY_RULE(int) yy_HtmlBlockCloseUl(GREG *G); /* 116 */ -YY_RULE(int) yy_HtmlBlockOpenUl(GREG *G); /* 115 */ -YY_RULE(int) yy_HtmlBlockTable(GREG *G); /* 114 */ -YY_RULE(int) yy_HtmlBlockCloseTable(GREG *G); /* 113 */ -YY_RULE(int) yy_HtmlBlockOpenTable(GREG *G); /* 112 */ -YY_RULE(int) yy_HtmlBlockPre(GREG *G); /* 111 */ -YY_RULE(int) yy_HtmlBlockClosePre(GREG *G); /* 110 */ -YY_RULE(int) yy_HtmlBlockOpenPre(GREG *G); /* 109 */ -YY_RULE(int) yy_HtmlBlockP(GREG *G); /* 108 */ -YY_RULE(int) yy_HtmlBlockCloseP(GREG *G); /* 107 */ -YY_RULE(int) yy_HtmlBlockOpenP(GREG *G); /* 106 */ -YY_RULE(int) yy_HtmlBlockOl(GREG *G); /* 105 */ -YY_RULE(int) yy_HtmlBlockCloseOl(GREG *G); /* 104 */ -YY_RULE(int) yy_HtmlBlockOpenOl(GREG *G); /* 103 */ -YY_RULE(int) yy_HtmlBlockNoscript(GREG *G); /* 102 */ -YY_RULE(int) yy_HtmlBlockCloseNoscript(GREG *G); /* 101 */ -YY_RULE(int) yy_HtmlBlockOpenNoscript(GREG *G); /* 100 */ -YY_RULE(int) yy_HtmlBlockNoframes(GREG *G); /* 99 */ -YY_RULE(int) yy_HtmlBlockCloseNoframes(GREG *G); /* 98 */ -YY_RULE(int) yy_HtmlBlockOpenNoframes(GREG *G); /* 97 */ -YY_RULE(int) yy_HtmlBlockMenu(GREG *G); /* 96 */ -YY_RULE(int) yy_HtmlBlockCloseMenu(GREG *G); /* 95 */ -YY_RULE(int) yy_HtmlBlockOpenMenu(GREG *G); /* 94 */ -YY_RULE(int) yy_HtmlBlockH6(GREG *G); /* 93 */ -YY_RULE(int) yy_HtmlBlockCloseH6(GREG *G); /* 92 */ -YY_RULE(int) yy_HtmlBlockOpenH6(GREG *G); /* 91 */ -YY_RULE(int) yy_HtmlBlockH5(GREG *G); /* 90 */ -YY_RULE(int) yy_HtmlBlockCloseH5(GREG *G); /* 89 */ -YY_RULE(int) yy_HtmlBlockOpenH5(GREG *G); /* 88 */ -YY_RULE(int) yy_HtmlBlockH4(GREG *G); /* 87 */ -YY_RULE(int) yy_HtmlBlockCloseH4(GREG *G); /* 86 */ -YY_RULE(int) yy_HtmlBlockOpenH4(GREG *G); /* 85 */ -YY_RULE(int) yy_HtmlBlockH3(GREG *G); /* 84 */ -YY_RULE(int) yy_HtmlBlockCloseH3(GREG *G); /* 83 */ -YY_RULE(int) yy_HtmlBlockOpenH3(GREG *G); /* 82 */ -YY_RULE(int) yy_HtmlBlockH2(GREG *G); /* 81 */ -YY_RULE(int) yy_HtmlBlockCloseH2(GREG *G); /* 80 */ -YY_RULE(int) yy_HtmlBlockOpenH2(GREG *G); /* 79 */ -YY_RULE(int) yy_HtmlBlockH1(GREG *G); /* 78 */ -YY_RULE(int) yy_HtmlBlockCloseH1(GREG *G); /* 77 */ -YY_RULE(int) yy_HtmlBlockOpenH1(GREG *G); /* 76 */ -YY_RULE(int) yy_HtmlBlockForm(GREG *G); /* 75 */ -YY_RULE(int) yy_HtmlBlockCloseForm(GREG *G); /* 74 */ -YY_RULE(int) yy_HtmlBlockOpenForm(GREG *G); /* 73 */ -YY_RULE(int) yy_HtmlBlockFieldset(GREG *G); /* 72 */ -YY_RULE(int) yy_HtmlBlockCloseFieldset(GREG *G); /* 71 */ -YY_RULE(int) yy_HtmlBlockOpenFieldset(GREG *G); /* 70 */ -YY_RULE(int) yy_HtmlBlockDl(GREG *G); /* 69 */ -YY_RULE(int) yy_HtmlBlockCloseDl(GREG *G); /* 68 */ -YY_RULE(int) yy_HtmlBlockOpenDl(GREG *G); /* 67 */ -YY_RULE(int) yy_HtmlBlockDiv(GREG *G); /* 66 */ -YY_RULE(int) yy_HtmlBlockCloseDiv(GREG *G); /* 65 */ -YY_RULE(int) yy_HtmlBlockOpenDiv(GREG *G); /* 64 */ -YY_RULE(int) yy_HtmlBlockDir(GREG *G); /* 63 */ -YY_RULE(int) yy_HtmlBlockCloseDir(GREG *G); /* 62 */ -YY_RULE(int) yy_HtmlBlockOpenDir(GREG *G); /* 61 */ -YY_RULE(int) yy_HtmlBlockCenter(GREG *G); /* 60 */ -YY_RULE(int) yy_HtmlBlockCloseCenter(GREG *G); /* 59 */ -YY_RULE(int) yy_HtmlBlockOpenCenter(GREG *G); /* 58 */ -YY_RULE(int) yy_HtmlBlockBlockquote(GREG *G); /* 57 */ -YY_RULE(int) yy_HtmlBlockCloseBlockquote(GREG *G); /* 56 */ -YY_RULE(int) yy_HtmlBlockOpenBlockquote(GREG *G); /* 55 */ -YY_RULE(int) yy_HtmlBlockAddress(GREG *G); /* 54 */ -YY_RULE(int) yy_HtmlBlockCloseAddress(GREG *G); /* 53 */ -YY_RULE(int) yy_HtmlAttribute(GREG *G); /* 52 */ -YY_RULE(int) yy_Spnl(GREG *G); /* 51 */ -YY_RULE(int) yy_HtmlBlockOpenAddress(GREG *G); /* 50 */ -YY_RULE(int) yy_OptionallyIndentedLine(GREG *G); /* 49 */ -YY_RULE(int) yy_Indent(GREG *G); /* 48 */ -YY_RULE(int) yy_ListBlockLine(GREG *G); /* 47 */ -YY_RULE(int) yy_ListContinuationBlock(GREG *G); /* 46 */ -YY_RULE(int) yy_ListBlock(GREG *G); /* 45 */ -YY_RULE(int) yy_ListItem(GREG *G); /* 44 */ -YY_RULE(int) yy_Enumerator(GREG *G); /* 43 */ -YY_RULE(int) yy_ListItemTight(GREG *G); /* 42 */ -YY_RULE(int) yy_ListLoose(GREG *G); /* 41 */ -YY_RULE(int) yy_ListTight(GREG *G); /* 40 */ -YY_RULE(int) yy_Spacechar(GREG *G); /* 39 */ -YY_RULE(int) yy_Bullet(GREG *G); /* 38 */ -YY_RULE(int) yy_VerbatimChunk(GREG *G); /* 37 */ -YY_RULE(int) yy_IndentedLine(GREG *G); /* 36 */ -YY_RULE(int) yy_NonblankIndentedLine(GREG *G); /* 35 */ -YY_RULE(int) yy_Line(GREG *G); /* 34 */ -YY_RULE(int) yy_StartList(GREG *G); /* 33 */ -YY_RULE(int) yy_BlockQuoteRaw(GREG *G); /* 32 */ -YY_RULE(int) yy_Endline(GREG *G); /* 31 */ -YY_RULE(int) yy_RawLine(GREG *G); /* 30 */ -YY_RULE(int) yy_SetextBottom2(GREG *G); /* 29 */ -YY_RULE(int) yy_SetextBottom1(GREG *G); /* 28 */ -YY_RULE(int) yy_SetextHeading2(GREG *G); /* 27 */ -YY_RULE(int) yy_SetextHeading1(GREG *G); /* 26 */ -YY_RULE(int) yy_SetextHeading(GREG *G); /* 25 */ -YY_RULE(int) yy_AtxHeading(GREG *G); /* 24 */ -YY_RULE(int) yy_AtxStart(GREG *G); /* 23 */ -YY_RULE(int) yy_Inline(GREG *G); /* 22 */ -YY_RULE(int) yy_Sp(GREG *G); /* 21 */ -YY_RULE(int) yy_Newline(GREG *G); /* 20 */ -YY_RULE(int) yy_AtxInline(GREG *G); /* 19 */ -YY_RULE(int) yy_Inlines(GREG *G); /* 18 */ -YY_RULE(int) yy_NonindentSpace(GREG *G); /* 17 */ -YY_RULE(int) yy_Plain(GREG *G); /* 16 */ -YY_RULE(int) yy_Para(GREG *G); /* 15 */ -YY_RULE(int) yy_StyleBlock(GREG *G); /* 14 */ -YY_RULE(int) yy_HtmlBlock(GREG *G); /* 13 */ -YY_RULE(int) yy_BulletList(GREG *G); /* 12 */ -YY_RULE(int) yy_OrderedList(GREG *G); /* 11 */ -YY_RULE(int) yy_Heading(GREG *G); /* 10 */ -YY_RULE(int) yy_HorizontalRule(GREG *G); /* 9 */ -YY_RULE(int) yy_Reference(GREG *G); /* 8 */ -YY_RULE(int) yy_Note(GREG *G); /* 7 */ -YY_RULE(int) yy_Verbatim(GREG *G); /* 6 */ -YY_RULE(int) yy_BlockQuote(GREG *G); /* 5 */ -YY_RULE(int) yy_BlankLine(GREG *G); /* 4 */ -YY_RULE(int) yy_LocMarker(GREG *G); /* 3 */ -YY_RULE(int) yy_Block(GREG *G); /* 2 */ -YY_RULE(int) yy_Doc(GREG *G); /* 1 */ - -YY_ACTION(void) yy_1_Dollar2Math(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Dollar2Math\n")); - ADD(elem(pmh_CODE)); ; -} -YY_ACTION(void) yy_1_Dollar1Math(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Dollar1Math\n")); - ADD(elem(pmh_CODE)); ; -} -YY_ACTION(void) yy_1_RawLine(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_RawLine\n")); - yy = elem(pmh_RAW); ; -} -YY_ACTION(void) yy_1_Line(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Line\n")); - yy = mk_element((parser_data *)G->data, pmh_RAW, yy->pos, yy->end); ; -} -YY_ACTION(void) yy_1_StartList(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_StartList\n")); - yy = NULL; ; -} -YY_ACTION(void) yy_1_HtmlComment(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_HtmlComment\n")); - ADD(elem_s(pmh_COMMENT)); ; -#undef s -} -YY_ACTION(void) yy_1_RawHtml(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_RawHtml\n")); - ADD(elem_s(pmh_HTML)); ; -#undef s -} -YY_ACTION(void) yy_1_Code(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_Code\n")); - ADD(elem_s(pmh_CODE)); ; -#undef s -} -YY_ACTION(void) yy_1_Waves5(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Waves5\n")); - yy = elem(pmh_NO_TYPE); ; -} -YY_ACTION(void) yy_1_Waves4(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Waves4\n")); - yy = elem(pmh_NO_TYPE); ; -} -YY_ACTION(void) yy_1_Waves3(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Waves3\n")); - yy = elem(pmh_NO_TYPE); ; -} -YY_ACTION(void) yy_1_Ticks5(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Ticks5\n")); - yy = elem(pmh_NO_TYPE); ; -} -YY_ACTION(void) yy_1_Ticks4(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Ticks4\n")); - yy = elem(pmh_NO_TYPE); ; -} -YY_ACTION(void) yy_1_Ticks3(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Ticks3\n")); - yy = elem(pmh_NO_TYPE); ; -} -YY_ACTION(void) yy_1_Ticks2(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Ticks2\n")); - yy = elem(pmh_NO_TYPE); ; -} -YY_ACTION(void) yy_1_Ticks1(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Ticks1\n")); - yy = elem(pmh_NO_TYPE); ; -} -YY_ACTION(void) yy_1_RefSrc(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_RefSrc\n")); - yy = mk_notype; yy->address = COPY_YYTEXT_ORIG(); ; -} -YY_ACTION(void) yy_2_Label(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_2_Label\n")); - - s->pos = s->pos; - s->end = thunk->end; - yy = s; - ; -#undef s -} -YY_ACTION(void) yy_1_Label(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_Label\n")); - s->label = COPY_YYTEXT_ORIG(); ; -#undef s -} -YY_ACTION(void) yy_1_Reference(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define r G->val[-1] -#define l G->val[-2] -#define s G->val[-3] - yyprintf((stderr, "do yy_1_Reference\n")); - - pmh_realelement *el = elem_s(pmh_REFERENCE); - el->label = strdup_or_null(l->label); - el->address = strdup_or_null(r->address); - ADD(el); - FREE_LABEL(l); - FREE_ADDRESS(r); - ; -#undef r -#undef l -#undef s -} -YY_ACTION(void) yy_3_AutoLinkEmail(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_3_AutoLinkEmail\n")); - - s->end = thunk->end; - ADD(s); - ; -#undef s -} -YY_ACTION(void) yy_2_AutoLinkEmail(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_2_AutoLinkEmail\n")); - s->address = COPY_YYTEXT_ORIG(); ; -#undef s -} -YY_ACTION(void) yy_1_AutoLinkEmail(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_AutoLinkEmail\n")); - s->type = pmh_AUTO_LINK_EMAIL; ; -#undef s -} -YY_ACTION(void) yy_3_AutoLinkUrl(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_3_AutoLinkUrl\n")); - - s->end = thunk->end; - ADD(s); - ; -#undef s -} -YY_ACTION(void) yy_2_AutoLinkUrl(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_2_AutoLinkUrl\n")); - s->address = COPY_YYTEXT_ORIG(); ; -#undef s -} -YY_ACTION(void) yy_1_AutoLinkUrl(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_AutoLinkUrl\n")); - s->type = pmh_AUTO_LINK_URL; ; -#undef s -} -YY_ACTION(void) yy_3_Source(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_3_Source\n")); - yy->address = COPY_YYTEXT_ORIG(); ; -} -YY_ACTION(void) yy_2_Source(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_2_Source\n")); - yy->address = COPY_YYTEXT_ORIG(); ; -} -YY_ACTION(void) yy_1_Source(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Source\n")); - yy = mk_notype; ; -} -YY_ACTION(void) yy_1_ExplicitLink(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define l G->val[-1] -#define s G->val[-2] - yyprintf((stderr, "do yy_1_ExplicitLink\n")); - - yy = elem_s(pmh_LINK); - if (l->address != NULL) - yy->address = strdup_or_null(l->address); - FREE_LABEL(s); - FREE_ADDRESS(l); - ; -#undef l -#undef s -} -YY_ACTION(void) yy_1_ReferenceLinkSingle(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_ReferenceLinkSingle\n")); - - pmh_realelement *reference = GET_REF(s->label); - if (reference) { - yy = elem_s(pmh_LINK); - yy->label = strdup_or_null(s->label); - yy->address = strdup_or_null(reference->address); - } else - yy = NULL; - FREE_LABEL(s); - ; -#undef s -} -YY_ACTION(void) yy_1_ReferenceLinkDouble(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define l G->val[-1] -#define s G->val[-2] - yyprintf((stderr, "do yy_1_ReferenceLinkDouble\n")); - - pmh_realelement *reference = GET_REF(l->label); - if (reference) { - yy = elem_s(pmh_LINK); - yy->label = strdup_or_null(l->label); - yy->address = strdup_or_null(reference->address); - } else - yy = NULL; - FREE_LABEL(s); - FREE_LABEL(l); - ; -#undef l -#undef s -} -YY_ACTION(void) yy_1_Link(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Link\n")); - if (yy) ADD(yy); ; -} -YY_ACTION(void) yy_1_Image(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Image\n")); - - if (yy != NULL) { - yy->type = pmh_IMAGE; - yy->pos -= 1; - ADD(yy); - } - ; -} -YY_ACTION(void) yy_1_StrongUl(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_StrongUl\n")); - ADD(elem_s(pmh_STRONG)); ; -#undef s -} -YY_ACTION(void) yy_1_StrongStar(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_StrongStar\n")); - ADD(elem_s(pmh_STRONG)); ; -#undef s -} -YY_ACTION(void) yy_1_EmphUl(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_EmphUl\n")); - ADD(elem_s(pmh_EMPH)); ; -#undef s -} -YY_ACTION(void) yy_1_EmphStar(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_EmphStar\n")); - ADD(elem_s(pmh_EMPH)); ; -#undef s -} -YY_ACTION(void) yy_1_Entity(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_Entity\n")); - ADD(elem_s(pmh_HTML_ENTITY)); ; -#undef s -} -YY_ACTION(void) yy_1_StyleBlock(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_StyleBlock\n")); - ADD(elem_s(pmh_HTMLBLOCK)); ; -#undef s -} -YY_ACTION(void) yy_1_HtmlBlock(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_HtmlBlock\n")); - ADD(elem_s(pmh_HTMLBLOCK)); ; -#undef s -} -YY_ACTION(void) yy_1_HtmlBlockH6(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_HtmlBlockH6\n")); - ADD(elem_s(pmh_H6)); ; -#undef s -} -YY_ACTION(void) yy_1_HtmlBlockH5(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_HtmlBlockH5\n")); - ADD(elem_s(pmh_H5)); ; -#undef s -} -YY_ACTION(void) yy_1_HtmlBlockH4(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_HtmlBlockH4\n")); - ADD(elem_s(pmh_H4)); ; -#undef s -} -YY_ACTION(void) yy_1_HtmlBlockH3(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_HtmlBlockH3\n")); - ADD(elem_s(pmh_H3)); ; -#undef s -} -YY_ACTION(void) yy_1_HtmlBlockH2(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_HtmlBlockH2\n")); - ADD(elem_s(pmh_H2)); ; -#undef s -} -YY_ACTION(void) yy_1_HtmlBlockH1(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_HtmlBlockH1\n")); - ADD(elem_s(pmh_H1)); ; -#undef s -} -YY_ACTION(void) yy_1_Enumerator(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Enumerator\n")); - ADD(elem(pmh_LIST_ENUMERATOR)); ; -} -YY_ACTION(void) yy_3_ListContinuationBlock(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_3_ListContinuationBlock\n")); - yy = a; ; -#undef a -} -YY_ACTION(void) yy_2_ListContinuationBlock(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_2_ListContinuationBlock\n")); - a = cons(yy, a); ; -#undef a -} -YY_ACTION(void) yy_1_ListContinuationBlock(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_1_ListContinuationBlock\n")); - if (*yytext == '\0') /* if strlen(yytext) == 0 */ - a = cons(elem(pmh_SEPARATOR), a); - else - a = cons(elem(pmh_RAW), a); - ; -#undef a -} -YY_ACTION(void) yy_3_ListBlock(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_3_ListBlock\n")); - yy = a; ; -#undef a -} -YY_ACTION(void) yy_2_ListBlock(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_2_ListBlock\n")); - a = cons(elem(pmh_RAW), a); ; -#undef a -} -YY_ACTION(void) yy_1_ListBlock(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_1_ListBlock\n")); - a = cons(yy, a); ; -#undef a -} -YY_ACTION(void) yy_3_ListItemTight(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_3_ListItemTight\n")); - yy = a; ; -#undef a -} -YY_ACTION(void) yy_2_ListItemTight(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_2_ListItemTight\n")); - a = cons(yy, a); ; -#undef a -} -YY_ACTION(void) yy_1_ListItemTight(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_1_ListItemTight\n")); - a = cons(yy, a); ; -#undef a -} -YY_ACTION(void) yy_3_ListItem(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_3_ListItem\n")); - yy = a; ; -#undef a -} -YY_ACTION(void) yy_2_ListItem(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_2_ListItem\n")); - a = cons(yy, a); ; -#undef a -} -YY_ACTION(void) yy_1_ListItem(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_1_ListItem\n")); - a = cons(yy, a); ; -#undef a -} -YY_ACTION(void) yy_2_ListLoose(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define b G->val[-1] -#define a G->val[-2] - yyprintf((stderr, "do yy_2_ListLoose\n")); - pmh_realelement *cur = a; - while (cur != NULL) { - pmh_realelement *rawlist = mk_element((parser_data *)G->data, pmh_RAW_LIST, 0,0); - rawlist->children = reverse(cur->children); - ADD(rawlist); - cur = cur->next; - } - ; -#undef b -#undef a -} -YY_ACTION(void) yy_1_ListLoose(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define b G->val[-1] -#define a G->val[-2] - yyprintf((stderr, "do yy_1_ListLoose\n")); - b = cons(etext("\n\n"), b); /* In loose list, \n\n added to end of each element */ - pmh_realelement *el = mk_notype; - el->children = b; - a = cons(el, a); - ; -#undef b -#undef a -} -YY_ACTION(void) yy_2_ListTight(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_2_ListTight\n")); - pmh_realelement *cur = a; - while (cur != NULL) { - pmh_realelement *rawlist = mk_element((parser_data *)G->data, pmh_RAW_LIST, 0,0); - rawlist->children = reverse(cur->children); - ADD(rawlist); - cur = cur->next; - } - ; -#undef a -} -YY_ACTION(void) yy_1_ListTight(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_1_ListTight\n")); - pmh_realelement *el = mk_notype; - el->children = yy; - a = cons(el, a); - ; -#undef a -} -YY_ACTION(void) yy_1_Bullet(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_Bullet\n")); - ADD(elem(pmh_LIST_BULLET)); ; -} -YY_ACTION(void) yy_1_HorizontalRule(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_HorizontalRule\n")); - ADD(elem(pmh_HRULE)); ; -} -YY_ACTION(void) yy_1_Verbatim(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_Verbatim\n")); - ADD(elem_s(pmh_VERBATIM)); ; -#undef s -} -YY_ACTION(void) yy_5_BlockQuoteRaw(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_5_BlockQuoteRaw\n")); - yy = a; ; -#undef a -} -YY_ACTION(void) yy_4_BlockQuoteRaw(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_4_BlockQuoteRaw\n")); - a = cons(etext("\n"), a); ; -#undef a -} -YY_ACTION(void) yy_3_BlockQuoteRaw(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_3_BlockQuoteRaw\n")); - a = cons(yy, a); ; -#undef a -} -YY_ACTION(void) yy_2_BlockQuoteRaw(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_2_BlockQuoteRaw\n")); - a = cons(yy, a); ; -#undef a -} -YY_ACTION(void) yy_1_BlockQuoteRaw(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_1_BlockQuoteRaw\n")); - ADD(elem(pmh_BLOCKQUOTE)); ; -#undef a -} -YY_ACTION(void) yy_1_BlockQuote(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define a G->val[-1] - yyprintf((stderr, "do yy_1_BlockQuote\n")); - pmh_realelement *rawlist = mk_element((parser_data *)G->data, pmh_RAW_LIST, 0,0); - rawlist->children = reverse(a); - ADD(rawlist); - ; -#undef a -} -YY_ACTION(void) yy_1_SetextHeading2(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_SetextHeading2\n")); - ADD(elem_s(pmh_H2)); ; -#undef s -} -YY_ACTION(void) yy_1_SetextHeading1(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_SetextHeading1\n")); - ADD(elem_s(pmh_H1)); ; -#undef s -} -YY_ACTION(void) yy_1_AtxHeading(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ -#define s G->val[-1] - yyprintf((stderr, "do yy_1_AtxHeading\n")); - ADD(elem_s(s->type)); ; -#undef s -} -YY_ACTION(void) yy_1_AtxStart(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_AtxStart\n")); - yy = elem((pmh_element_type)(pmh_H1 + (strlen(yytext) - 1))); ; -} -YY_ACTION(void) yy_1_LocMarker(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) -{ - yyprintf((stderr, "do yy_1_LocMarker\n")); - yy = elem(pmh_NO_TYPE); ; -} - -YY_RULE(int) yy_Dollar2Math(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Dollar2Math")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1; if (!yymatchString(G, "$$")) goto l1; - { int yypos4= G->pos, yythunkpos4= G->thunkpos; if (!yymatchChar(G, '$')) goto l4; goto l1; - l4:; G->pos= yypos4; G->thunkpos= yythunkpos4; - } if (!yymatchDot(G)) goto l1; - l2:; - { int yypos3= G->pos, yythunkpos3= G->thunkpos; - { int yypos5= G->pos, yythunkpos5= G->thunkpos; if (!yymatchChar(G, '$')) goto l5; goto l3; - l5:; G->pos= yypos5; G->thunkpos= yythunkpos5; - } if (!yymatchDot(G)) goto l3; goto l2; - l3:; G->pos= yypos3; G->thunkpos= yythunkpos3; - } if (!yymatchString(G, "$$")) goto l1; yyText(G, G->begin, G->end); if (!(YY_END)) goto l1; yyDo(G, yy_1_Dollar2Math, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Dollar2Math", G->buf+G->pos)); - return 1; - l1:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Dollar2Math", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Dollar1Math(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Dollar1Math")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l6; if (!yymatchChar(G, '$')) goto l6; - { int yypos9= G->pos, yythunkpos9= G->thunkpos; if (!yymatchChar(G, '$')) goto l9; goto l6; - l9:; G->pos= yypos9; G->thunkpos= yythunkpos9; - } if (!yymatchDot(G)) goto l6; - l7:; - { int yypos8= G->pos, yythunkpos8= G->thunkpos; - { int yypos10= G->pos, yythunkpos10= G->thunkpos; if (!yymatchChar(G, '$')) goto l10; goto l8; - l10:; G->pos= yypos10; G->thunkpos= yythunkpos10; - } if (!yymatchDot(G)) goto l8; goto l7; - l8:; G->pos= yypos8; G->thunkpos= yythunkpos8; - } if (!yymatchChar(G, '$')) goto l6; yyText(G, G->begin, G->end); if (!(YY_END)) goto l6; yyDo(G, yy_1_Dollar1Math, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Dollar1Math", G->buf+G->pos)); - return 1; - l6:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Dollar1Math", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_RawNoteBlock(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "RawNoteBlock")); - { int yypos14= G->pos, yythunkpos14= G->thunkpos; if (!yy_BlankLine(G)) { goto l14; } goto l11; - l14:; G->pos= yypos14; G->thunkpos= yythunkpos14; - } if (!yy_OptionallyIndentedLine(G)) { goto l11; } - l12:; - { int yypos13= G->pos, yythunkpos13= G->thunkpos; - { int yypos15= G->pos, yythunkpos15= G->thunkpos; if (!yy_BlankLine(G)) { goto l15; } goto l13; - l15:; G->pos= yypos15; G->thunkpos= yythunkpos15; - } if (!yy_OptionallyIndentedLine(G)) { goto l13; } goto l12; - l13:; G->pos= yypos13; G->thunkpos= yythunkpos13; - } - l16:; - { int yypos17= G->pos, yythunkpos17= G->thunkpos; if (!yy_BlankLine(G)) { goto l17; } goto l16; - l17:; G->pos= yypos17; G->thunkpos= yythunkpos17; - } - yyprintf((stderr, " ok %s @ %s\n", "RawNoteBlock", G->buf+G->pos)); - return 1; - l11:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "RawNoteBlock", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_RawNoteReference(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "RawNoteReference")); if (!yymatchString(G, "[^")) goto l18; - { int yypos21= G->pos, yythunkpos21= G->thunkpos; if (!yy_Newline(G)) { goto l21; } goto l18; - l21:; G->pos= yypos21; G->thunkpos= yythunkpos21; - } - { int yypos22= G->pos, yythunkpos22= G->thunkpos; if (!yymatchChar(G, ']')) goto l22; goto l18; - l22:; G->pos= yypos22; G->thunkpos= yythunkpos22; - } if (!yymatchDot(G)) goto l18; - l19:; - { int yypos20= G->pos, yythunkpos20= G->thunkpos; - { int yypos23= G->pos, yythunkpos23= G->thunkpos; if (!yy_Newline(G)) { goto l23; } goto l20; - l23:; G->pos= yypos23; G->thunkpos= yythunkpos23; - } - { int yypos24= G->pos, yythunkpos24= G->thunkpos; if (!yymatchChar(G, ']')) goto l24; goto l20; - l24:; G->pos= yypos24; G->thunkpos= yythunkpos24; - } if (!yymatchDot(G)) goto l20; goto l19; - l20:; G->pos= yypos20; G->thunkpos= yythunkpos20; - } if (!yymatchChar(G, ']')) goto l18; - yyprintf((stderr, " ok %s @ %s\n", "RawNoteReference", G->buf+G->pos)); - return 1; - l18:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "RawNoteReference", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ExtendedSpecialChar(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "ExtendedSpecialChar")); yyText(G, G->begin, G->end); if (!( EXT(pmh_EXT_NOTES) )) goto l25; if (!yymatchChar(G, '^')) goto l25; - yyprintf((stderr, " ok %s @ %s\n", "ExtendedSpecialChar", G->buf+G->pos)); - return 1; - l25:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ExtendedSpecialChar", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_AlphanumericAscii(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "AlphanumericAscii")); if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\377\003\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l26; - yyprintf((stderr, " ok %s @ %s\n", "AlphanumericAscii", G->buf+G->pos)); - return 1; - l26:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "AlphanumericAscii", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Quoted(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Quoted")); - { int yypos28= G->pos, yythunkpos28= G->thunkpos; if (!yymatchChar(G, '"')) goto l29; - l30:; - { int yypos31= G->pos, yythunkpos31= G->thunkpos; - { int yypos32= G->pos, yythunkpos32= G->thunkpos; if (!yymatchChar(G, '"')) goto l32; goto l31; - l32:; G->pos= yypos32; G->thunkpos= yythunkpos32; - } if (!yymatchDot(G)) goto l31; goto l30; - l31:; G->pos= yypos31; G->thunkpos= yythunkpos31; - } if (!yymatchChar(G, '"')) goto l29; goto l28; - l29:; G->pos= yypos28; G->thunkpos= yythunkpos28; if (!yymatchChar(G, '\'')) goto l27; - l33:; - { int yypos34= G->pos, yythunkpos34= G->thunkpos; - { int yypos35= G->pos, yythunkpos35= G->thunkpos; if (!yymatchChar(G, '\'')) goto l35; goto l34; - l35:; G->pos= yypos35; G->thunkpos= yythunkpos35; - } if (!yymatchDot(G)) goto l34; goto l33; - l34:; G->pos= yypos34; G->thunkpos= yythunkpos34; - } if (!yymatchChar(G, '\'')) goto l27; - } - l28:; - yyprintf((stderr, " ok %s @ %s\n", "Quoted", G->buf+G->pos)); - return 1; - l27:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Quoted", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlTag(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlTag")); if (!yymatchChar(G, '<')) goto l36; if (!yy_Spnl(G)) { goto l36; } - { int yypos37= G->pos, yythunkpos37= G->thunkpos; if (!yymatchChar(G, '/')) goto l37; goto l38; - l37:; G->pos= yypos37; G->thunkpos= yythunkpos37; - } - l38:; if (!yy_AlphanumericAscii(G)) { goto l36; } - l39:; - { int yypos40= G->pos, yythunkpos40= G->thunkpos; if (!yy_AlphanumericAscii(G)) { goto l40; } goto l39; - l40:; G->pos= yypos40; G->thunkpos= yythunkpos40; - } if (!yy_Spnl(G)) { goto l36; } - l41:; - { int yypos42= G->pos, yythunkpos42= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l42; } goto l41; - l42:; G->pos= yypos42; G->thunkpos= yythunkpos42; - } - { int yypos43= G->pos, yythunkpos43= G->thunkpos; if (!yymatchChar(G, '/')) goto l43; goto l44; - l43:; G->pos= yypos43; G->thunkpos= yythunkpos43; - } - l44:; if (!yy_Spnl(G)) { goto l36; } if (!yymatchChar(G, '>')) goto l36; - yyprintf((stderr, " ok %s @ %s\n", "HtmlTag", G->buf+G->pos)); - return 1; - l36:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlTag", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Waves5(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Waves5")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l45; if (!yymatchString(G, "~~~~~")) goto l45; yyText(G, G->begin, G->end); if (!(YY_END)) goto l45; - { int yypos46= G->pos, yythunkpos46= G->thunkpos; if (!yymatchChar(G, '~')) goto l46; goto l45; - l46:; G->pos= yypos46; G->thunkpos= yythunkpos46; - } yyDo(G, yy_1_Waves5, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Waves5", G->buf+G->pos)); - return 1; - l45:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Waves5", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Waves4(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Waves4")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l47; if (!yymatchString(G, "~~~~")) goto l47; yyText(G, G->begin, G->end); if (!(YY_END)) goto l47; - { int yypos48= G->pos, yythunkpos48= G->thunkpos; if (!yymatchChar(G, '~')) goto l48; goto l47; - l48:; G->pos= yypos48; G->thunkpos= yythunkpos48; - } yyDo(G, yy_1_Waves4, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Waves4", G->buf+G->pos)); - return 1; - l47:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Waves4", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Waves3(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Waves3")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l49; if (!yymatchString(G, "~~~")) goto l49; yyText(G, G->begin, G->end); if (!(YY_END)) goto l49; - { int yypos50= G->pos, yythunkpos50= G->thunkpos; if (!yymatchChar(G, '~')) goto l50; goto l49; - l50:; G->pos= yypos50; G->thunkpos= yythunkpos50; - } yyDo(G, yy_1_Waves3, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Waves3", G->buf+G->pos)); - return 1; - l49:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Waves3", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Ticks5(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Ticks5")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l51; if (!yymatchString(G, "`````")) goto l51; yyText(G, G->begin, G->end); if (!(YY_END)) goto l51; - { int yypos52= G->pos, yythunkpos52= G->thunkpos; if (!yymatchChar(G, '`')) goto l52; goto l51; - l52:; G->pos= yypos52; G->thunkpos= yythunkpos52; - } yyDo(G, yy_1_Ticks5, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Ticks5", G->buf+G->pos)); - return 1; - l51:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Ticks5", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Ticks4(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Ticks4")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l53; if (!yymatchString(G, "````")) goto l53; yyText(G, G->begin, G->end); if (!(YY_END)) goto l53; - { int yypos54= G->pos, yythunkpos54= G->thunkpos; if (!yymatchChar(G, '`')) goto l54; goto l53; - l54:; G->pos= yypos54; G->thunkpos= yythunkpos54; - } yyDo(G, yy_1_Ticks4, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Ticks4", G->buf+G->pos)); - return 1; - l53:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Ticks4", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Ticks3(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Ticks3")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l55; if (!yymatchString(G, "```")) goto l55; yyText(G, G->begin, G->end); if (!(YY_END)) goto l55; - { int yypos56= G->pos, yythunkpos56= G->thunkpos; if (!yymatchChar(G, '`')) goto l56; goto l55; - l56:; G->pos= yypos56; G->thunkpos= yythunkpos56; - } yyDo(G, yy_1_Ticks3, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Ticks3", G->buf+G->pos)); - return 1; - l55:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Ticks3", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Ticks2(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Ticks2")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l57; if (!yymatchString(G, "``")) goto l57; yyText(G, G->begin, G->end); if (!(YY_END)) goto l57; - { int yypos58= G->pos, yythunkpos58= G->thunkpos; if (!yymatchChar(G, '`')) goto l58; goto l57; - l58:; G->pos= yypos58; G->thunkpos= yythunkpos58; - } yyDo(G, yy_1_Ticks2, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Ticks2", G->buf+G->pos)); - return 1; - l57:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Ticks2", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Ticks1(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Ticks1")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l59; if (!yymatchChar(G, '`')) goto l59; yyText(G, G->begin, G->end); if (!(YY_END)) goto l59; - { int yypos60= G->pos, yythunkpos60= G->thunkpos; if (!yymatchChar(G, '`')) goto l60; goto l59; - l60:; G->pos= yypos60; G->thunkpos= yythunkpos60; - } yyDo(G, yy_1_Ticks1, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Ticks1", G->buf+G->pos)); - return 1; - l59:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Ticks1", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_SkipBlock(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "SkipBlock")); - { int yypos62= G->pos, yythunkpos62= G->thunkpos; - { int yypos66= G->pos, yythunkpos66= G->thunkpos; if (!yy_BlankLine(G)) { goto l66; } goto l63; - l66:; G->pos= yypos66; G->thunkpos= yythunkpos66; - } if (!yy_RawLine(G)) { goto l63; } - l64:; - { int yypos65= G->pos, yythunkpos65= G->thunkpos; - { int yypos67= G->pos, yythunkpos67= G->thunkpos; if (!yy_BlankLine(G)) { goto l67; } goto l65; - l67:; G->pos= yypos67; G->thunkpos= yythunkpos67; - } if (!yy_RawLine(G)) { goto l65; } goto l64; - l65:; G->pos= yypos65; G->thunkpos= yythunkpos65; - } - l68:; - { int yypos69= G->pos, yythunkpos69= G->thunkpos; if (!yy_BlankLine(G)) { goto l69; } goto l68; - l69:; G->pos= yypos69; G->thunkpos= yythunkpos69; - } goto l62; - l63:; G->pos= yypos62; G->thunkpos= yythunkpos62; if (!yy_BlankLine(G)) { goto l61; } - l70:; - { int yypos71= G->pos, yythunkpos71= G->thunkpos; if (!yy_BlankLine(G)) { goto l71; } goto l70; - l71:; G->pos= yypos71; G->thunkpos= yythunkpos71; - } - } - l62:; - yyprintf((stderr, " ok %s @ %s\n", "SkipBlock", G->buf+G->pos)); - return 1; - l61:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SkipBlock", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_References(GREG *G) -{ - yyprintf((stderr, "%s\n", "References")); - l73:; - { int yypos74= G->pos, yythunkpos74= G->thunkpos; - { int yypos75= G->pos, yythunkpos75= G->thunkpos; if (!yy_Reference(G)) { goto l76; } goto l75; - l76:; G->pos= yypos75; G->thunkpos= yythunkpos75; if (!yy_SkipBlock(G)) { goto l74; } - } - l75:; goto l73; - l74:; G->pos= yypos74; G->thunkpos= yythunkpos74; - } - yyprintf((stderr, " ok %s @ %s\n", "References", G->buf+G->pos)); - return 1; -} -YY_RULE(int) yy_EmptyTitle(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "EmptyTitle")); if (!yymatchString(G, "")) goto l77; - yyprintf((stderr, " ok %s @ %s\n", "EmptyTitle", G->buf+G->pos)); - return 1; - l77:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "EmptyTitle", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_RefTitleParens(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "RefTitleParens")); if (!yy_Spnl(G)) { goto l78; } if (!yymatchChar(G, '(')) goto l78; - l79:; - { int yypos80= G->pos, yythunkpos80= G->thunkpos; - { int yypos81= G->pos, yythunkpos81= G->thunkpos; - { int yypos82= G->pos, yythunkpos82= G->thunkpos; if (!yymatchChar(G, ')')) goto l83; if (!yy_Sp(G)) { goto l83; } if (!yy_Newline(G)) { goto l83; } goto l82; - l83:; G->pos= yypos82; G->thunkpos= yythunkpos82; if (!yy_Newline(G)) { goto l81; } - } - l82:; goto l80; - l81:; G->pos= yypos81; G->thunkpos= yythunkpos81; - } if (!yymatchDot(G)) goto l80; goto l79; - l80:; G->pos= yypos80; G->thunkpos= yythunkpos80; - } if (!yymatchChar(G, ')')) goto l78; - yyprintf((stderr, " ok %s @ %s\n", "RefTitleParens", G->buf+G->pos)); - return 1; - l78:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "RefTitleParens", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_RefTitleDouble(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "RefTitleDouble")); if (!yy_Spnl(G)) { goto l84; } if (!yymatchChar(G, '"')) goto l84; - l85:; - { int yypos86= G->pos, yythunkpos86= G->thunkpos; - { int yypos87= G->pos, yythunkpos87= G->thunkpos; - { int yypos88= G->pos, yythunkpos88= G->thunkpos; if (!yymatchChar(G, '"')) goto l89; if (!yy_Sp(G)) { goto l89; } if (!yy_Newline(G)) { goto l89; } goto l88; - l89:; G->pos= yypos88; G->thunkpos= yythunkpos88; if (!yy_Newline(G)) { goto l87; } - } - l88:; goto l86; - l87:; G->pos= yypos87; G->thunkpos= yythunkpos87; - } if (!yymatchDot(G)) goto l86; goto l85; - l86:; G->pos= yypos86; G->thunkpos= yythunkpos86; - } if (!yymatchChar(G, '"')) goto l84; - yyprintf((stderr, " ok %s @ %s\n", "RefTitleDouble", G->buf+G->pos)); - return 1; - l84:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "RefTitleDouble", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_RefTitleSingle(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "RefTitleSingle")); if (!yy_Spnl(G)) { goto l90; } if (!yymatchChar(G, '\'')) goto l90; - l91:; - { int yypos92= G->pos, yythunkpos92= G->thunkpos; - { int yypos93= G->pos, yythunkpos93= G->thunkpos; - { int yypos94= G->pos, yythunkpos94= G->thunkpos; if (!yymatchChar(G, '\'')) goto l95; if (!yy_Sp(G)) { goto l95; } if (!yy_Newline(G)) { goto l95; } goto l94; - l95:; G->pos= yypos94; G->thunkpos= yythunkpos94; if (!yy_Newline(G)) { goto l93; } - } - l94:; goto l92; - l93:; G->pos= yypos93; G->thunkpos= yythunkpos93; - } if (!yymatchDot(G)) goto l92; goto l91; - l92:; G->pos= yypos92; G->thunkpos= yythunkpos92; - } if (!yymatchChar(G, '\'')) goto l90; - yyprintf((stderr, " ok %s @ %s\n", "RefTitleSingle", G->buf+G->pos)); - return 1; - l90:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "RefTitleSingle", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_RefTitle(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "RefTitle")); - { int yypos97= G->pos, yythunkpos97= G->thunkpos; if (!yy_RefTitleSingle(G)) { goto l98; } goto l97; - l98:; G->pos= yypos97; G->thunkpos= yythunkpos97; if (!yy_RefTitleDouble(G)) { goto l99; } goto l97; - l99:; G->pos= yypos97; G->thunkpos= yythunkpos97; if (!yy_RefTitleParens(G)) { goto l100; } goto l97; - l100:; G->pos= yypos97; G->thunkpos= yythunkpos97; if (!yy_EmptyTitle(G)) { goto l96; } - } - l97:; - yyprintf((stderr, " ok %s @ %s\n", "RefTitle", G->buf+G->pos)); - return 1; - l96:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "RefTitle", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_RefSrc(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "RefSrc")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l101; if (!yy_Nonspacechar(G)) { goto l101; } - l102:; - { int yypos103= G->pos, yythunkpos103= G->thunkpos; if (!yy_Nonspacechar(G)) { goto l103; } goto l102; - l103:; G->pos= yypos103; G->thunkpos= yythunkpos103; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l101; yyDo(G, yy_1_RefSrc, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "RefSrc", G->buf+G->pos)); - return 1; - l101:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "RefSrc", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_AutoLinkEmail(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "AutoLinkEmail")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l104; if (!yy_LocMarker(G)) { goto l104; } yyDo(G, yySet, -1, 0); yyDo(G, yy_1_AutoLinkEmail, G->begin, G->end); if (!yymatchChar(G, '<')) goto l104; - { int yypos105= G->pos, yythunkpos105= G->thunkpos; if (!yymatchString(G, "mailto:")) goto l105; goto l106; - l105:; G->pos= yypos105; G->thunkpos= yythunkpos105; - } - l106:; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l104; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\062\350\377\003\376\377\377\207\376\377\377\107\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l104; - l107:; - { int yypos108= G->pos, yythunkpos108= G->thunkpos; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\062\350\377\003\376\377\377\207\376\377\377\107\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l108; goto l107; - l108:; G->pos= yypos108; G->thunkpos= yythunkpos108; - } if (!yymatchChar(G, '@')) goto l104; - { int yypos111= G->pos, yythunkpos111= G->thunkpos; if (!yy_Newline(G)) { goto l111; } goto l104; - l111:; G->pos= yypos111; G->thunkpos= yythunkpos111; - } - { int yypos112= G->pos, yythunkpos112= G->thunkpos; if (!yymatchChar(G, '>')) goto l112; goto l104; - l112:; G->pos= yypos112; G->thunkpos= yythunkpos112; - } if (!yymatchDot(G)) goto l104; - l109:; - { int yypos110= G->pos, yythunkpos110= G->thunkpos; - { int yypos113= G->pos, yythunkpos113= G->thunkpos; if (!yy_Newline(G)) { goto l113; } goto l110; - l113:; G->pos= yypos113; G->thunkpos= yythunkpos113; - } - { int yypos114= G->pos, yythunkpos114= G->thunkpos; if (!yymatchChar(G, '>')) goto l114; goto l110; - l114:; G->pos= yypos114; G->thunkpos= yythunkpos114; - } if (!yymatchDot(G)) goto l110; goto l109; - l110:; G->pos= yypos110; G->thunkpos= yythunkpos110; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l104; yyDo(G, yy_2_AutoLinkEmail, G->begin, G->end); if (!yymatchChar(G, '>')) goto l104; yyText(G, G->begin, G->end); if (!(YY_END)) goto l104; yyDo(G, yy_3_AutoLinkEmail, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "AutoLinkEmail", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l104:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "AutoLinkEmail", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_AutoLinkUrl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "AutoLinkUrl")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l115; if (!yy_LocMarker(G)) { goto l115; } yyDo(G, yySet, -1, 0); yyDo(G, yy_1_AutoLinkUrl, G->begin, G->end); if (!yymatchChar(G, '<')) goto l115; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l115; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l115; - l116:; - { int yypos117= G->pos, yythunkpos117= G->thunkpos; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l117; goto l116; - l117:; G->pos= yypos117; G->thunkpos= yythunkpos117; - } if (!yymatchString(G, "://")) goto l115; - { int yypos120= G->pos, yythunkpos120= G->thunkpos; if (!yy_Newline(G)) { goto l120; } goto l115; - l120:; G->pos= yypos120; G->thunkpos= yythunkpos120; - } - { int yypos121= G->pos, yythunkpos121= G->thunkpos; if (!yymatchChar(G, '>')) goto l121; goto l115; - l121:; G->pos= yypos121; G->thunkpos= yythunkpos121; - } if (!yymatchDot(G)) goto l115; - l118:; - { int yypos119= G->pos, yythunkpos119= G->thunkpos; - { int yypos122= G->pos, yythunkpos122= G->thunkpos; if (!yy_Newline(G)) { goto l122; } goto l119; - l122:; G->pos= yypos122; G->thunkpos= yythunkpos122; - } - { int yypos123= G->pos, yythunkpos123= G->thunkpos; if (!yymatchChar(G, '>')) goto l123; goto l119; - l123:; G->pos= yypos123; G->thunkpos= yythunkpos123; - } if (!yymatchDot(G)) goto l119; goto l118; - l119:; G->pos= yypos119; G->thunkpos= yythunkpos119; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l115; yyDo(G, yy_2_AutoLinkUrl, G->begin, G->end); if (!yymatchChar(G, '>')) goto l115; yyText(G, G->begin, G->end); if (!(YY_END)) goto l115; yyDo(G, yy_3_AutoLinkUrl, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "AutoLinkUrl", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l115:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "AutoLinkUrl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_TitleDouble(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "TitleDouble")); if (!yymatchChar(G, '"')) goto l124; - l125:; - { int yypos126= G->pos, yythunkpos126= G->thunkpos; - { int yypos127= G->pos, yythunkpos127= G->thunkpos; if (!yymatchChar(G, '"')) goto l127; if (!yy_Sp(G)) { goto l127; } - { int yypos128= G->pos, yythunkpos128= G->thunkpos; if (!yymatchChar(G, ')')) goto l129; goto l128; - l129:; G->pos= yypos128; G->thunkpos= yythunkpos128; if (!yy_Newline(G)) { goto l127; } - } - l128:; goto l126; - l127:; G->pos= yypos127; G->thunkpos= yythunkpos127; - } if (!yymatchDot(G)) goto l126; goto l125; - l126:; G->pos= yypos126; G->thunkpos= yythunkpos126; - } if (!yymatchChar(G, '"')) goto l124; - yyprintf((stderr, " ok %s @ %s\n", "TitleDouble", G->buf+G->pos)); - return 1; - l124:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "TitleDouble", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_TitleSingle(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "TitleSingle")); if (!yymatchChar(G, '\'')) goto l130; - l131:; - { int yypos132= G->pos, yythunkpos132= G->thunkpos; - { int yypos133= G->pos, yythunkpos133= G->thunkpos; if (!yymatchChar(G, '\'')) goto l133; if (!yy_Sp(G)) { goto l133; } - { int yypos134= G->pos, yythunkpos134= G->thunkpos; if (!yymatchChar(G, ')')) goto l135; goto l134; - l135:; G->pos= yypos134; G->thunkpos= yythunkpos134; if (!yy_Newline(G)) { goto l133; } - } - l134:; goto l132; - l133:; G->pos= yypos133; G->thunkpos= yythunkpos133; - } if (!yymatchDot(G)) goto l132; goto l131; - l132:; G->pos= yypos132; G->thunkpos= yythunkpos132; - } if (!yymatchChar(G, '\'')) goto l130; - yyprintf((stderr, " ok %s @ %s\n", "TitleSingle", G->buf+G->pos)); - return 1; - l130:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "TitleSingle", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Nonspacechar(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Nonspacechar")); - { int yypos137= G->pos, yythunkpos137= G->thunkpos; if (!yy_Spacechar(G)) { goto l137; } goto l136; - l137:; G->pos= yypos137; G->thunkpos= yythunkpos137; - } - { int yypos138= G->pos, yythunkpos138= G->thunkpos; if (!yy_Newline(G)) { goto l138; } goto l136; - l138:; G->pos= yypos138; G->thunkpos= yythunkpos138; - } if (!yymatchDot(G)) goto l136; - yyprintf((stderr, " ok %s @ %s\n", "Nonspacechar", G->buf+G->pos)); - return 1; - l136:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Nonspacechar", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_SourceContents(GREG *G) -{ - yyprintf((stderr, "%s\n", "SourceContents")); - l140:; - { int yypos141= G->pos, yythunkpos141= G->thunkpos; - { int yypos142= G->pos, yythunkpos142= G->thunkpos; - { int yypos146= G->pos, yythunkpos146= G->thunkpos; if (!yymatchChar(G, '(')) goto l146; goto l143; - l146:; G->pos= yypos146; G->thunkpos= yythunkpos146; - } - { int yypos147= G->pos, yythunkpos147= G->thunkpos; if (!yymatchChar(G, ')')) goto l147; goto l143; - l147:; G->pos= yypos147; G->thunkpos= yythunkpos147; - } - { int yypos148= G->pos, yythunkpos148= G->thunkpos; if (!yymatchChar(G, '>')) goto l148; goto l143; - l148:; G->pos= yypos148; G->thunkpos= yythunkpos148; - } if (!yy_Nonspacechar(G)) { goto l143; } - l144:; - { int yypos145= G->pos, yythunkpos145= G->thunkpos; - { int yypos149= G->pos, yythunkpos149= G->thunkpos; if (!yymatchChar(G, '(')) goto l149; goto l145; - l149:; G->pos= yypos149; G->thunkpos= yythunkpos149; - } - { int yypos150= G->pos, yythunkpos150= G->thunkpos; if (!yymatchChar(G, ')')) goto l150; goto l145; - l150:; G->pos= yypos150; G->thunkpos= yythunkpos150; - } - { int yypos151= G->pos, yythunkpos151= G->thunkpos; if (!yymatchChar(G, '>')) goto l151; goto l145; - l151:; G->pos= yypos151; G->thunkpos= yythunkpos151; - } if (!yy_Nonspacechar(G)) { goto l145; } goto l144; - l145:; G->pos= yypos145; G->thunkpos= yythunkpos145; - } goto l142; - l143:; G->pos= yypos142; G->thunkpos= yythunkpos142; if (!yymatchChar(G, '(')) goto l141; if (!yy_SourceContents(G)) { goto l141; } if (!yymatchChar(G, ')')) goto l141; - } - l142:; goto l140; - l141:; G->pos= yypos141; G->thunkpos= yythunkpos141; - } - yyprintf((stderr, " ok %s @ %s\n", "SourceContents", G->buf+G->pos)); - return 1; -} -YY_RULE(int) yy_Title(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Title")); - { int yypos153= G->pos, yythunkpos153= G->thunkpos; if (!yy_TitleSingle(G)) { goto l154; } goto l153; - l154:; G->pos= yypos153; G->thunkpos= yythunkpos153; if (!yy_TitleDouble(G)) { goto l155; } goto l153; - l155:; G->pos= yypos153; G->thunkpos= yythunkpos153; if (!yymatchString(G, "")) goto l152; - } - l153:; - yyprintf((stderr, " ok %s @ %s\n", "Title", G->buf+G->pos)); - return 1; - l152:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Title", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Source(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Source")); yyDo(G, yy_1_Source, G->begin, G->end); - { int yypos157= G->pos, yythunkpos157= G->thunkpos; if (!yymatchChar(G, '<')) goto l158; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l158; if (!yy_SourceContents(G)) { goto l158; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l158; yyDo(G, yy_2_Source, G->begin, G->end); if (!yymatchChar(G, '>')) goto l158; goto l157; - l158:; G->pos= yypos157; G->thunkpos= yythunkpos157; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l156; if (!yy_SourceContents(G)) { goto l156; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l156; yyDo(G, yy_3_Source, G->begin, G->end); - } - l157:; - yyprintf((stderr, " ok %s @ %s\n", "Source", G->buf+G->pos)); - return 1; - l156:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Source", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Label(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "Label")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l159; if (!yy_LocMarker(G)) { goto l159; } yyDo(G, yySet, -1, 0); if (!yymatchChar(G, '[')) goto l159; - { int yypos160= G->pos, yythunkpos160= G->thunkpos; - { int yypos162= G->pos, yythunkpos162= G->thunkpos; if (!yymatchChar(G, '^')) goto l162; goto l161; - l162:; G->pos= yypos162; G->thunkpos= yythunkpos162; - } yyText(G, G->begin, G->end); if (!( EXT(pmh_EXT_NOTES) )) goto l161; goto l160; - l161:; G->pos= yypos160; G->thunkpos= yythunkpos160; - { int yypos163= G->pos, yythunkpos163= G->thunkpos; if (!yymatchDot(G)) goto l159; G->pos= yypos163; G->thunkpos= yythunkpos163; - } yyText(G, G->begin, G->end); if (!( !EXT(pmh_EXT_NOTES) )) goto l159; - } - l160:; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l159; - l164:; - { int yypos165= G->pos, yythunkpos165= G->thunkpos; - { int yypos166= G->pos, yythunkpos166= G->thunkpos; if (!yymatchChar(G, ']')) goto l166; goto l165; - l166:; G->pos= yypos166; G->thunkpos= yythunkpos166; - } if (!yy_Inline(G)) { goto l165; } goto l164; - l165:; G->pos= yypos165; G->thunkpos= yythunkpos165; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l159; yyDo(G, yy_1_Label, G->begin, G->end); if (!yymatchChar(G, ']')) goto l159; yyText(G, G->begin, G->end); if (!(YY_END)) goto l159; yyDo(G, yy_2_Label, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Label", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l159:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Label", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ReferenceLinkSingle(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "ReferenceLinkSingle")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l167; if (!yy_Label(G)) { goto l167; } yyDo(G, yySet, -1, 0); - { int yypos168= G->pos, yythunkpos168= G->thunkpos; if (!yy_Spnl(G)) { goto l168; } if (!yymatchString(G, "[]")) goto l168; goto l169; - l168:; G->pos= yypos168; G->thunkpos= yythunkpos168; - } - l169:; yyText(G, G->begin, G->end); if (!(YY_END)) goto l167; yyDo(G, yy_1_ReferenceLinkSingle, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "ReferenceLinkSingle", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l167:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ReferenceLinkSingle", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ReferenceLinkDouble(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 2, 0); - yyprintf((stderr, "%s\n", "ReferenceLinkDouble")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l170; if (!yy_Label(G)) { goto l170; } yyDo(G, yySet, -2, 0); if (!yy_Spnl(G)) { goto l170; } - { int yypos171= G->pos, yythunkpos171= G->thunkpos; if (!yymatchString(G, "[]")) goto l171; goto l170; - l171:; G->pos= yypos171; G->thunkpos= yythunkpos171; - } if (!yy_Label(G)) { goto l170; } yyDo(G, yySet, -1, 0); yyText(G, G->begin, G->end); if (!(YY_END)) goto l170; yyDo(G, yy_1_ReferenceLinkDouble, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "ReferenceLinkDouble", G->buf+G->pos)); yyDo(G, yyPop, 2, 0); - return 1; - l170:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ReferenceLinkDouble", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_AutoLink(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "AutoLink")); - { int yypos173= G->pos, yythunkpos173= G->thunkpos; if (!yy_AutoLinkUrl(G)) { goto l174; } goto l173; - l174:; G->pos= yypos173; G->thunkpos= yythunkpos173; if (!yy_AutoLinkEmail(G)) { goto l172; } - } - l173:; - yyprintf((stderr, " ok %s @ %s\n", "AutoLink", G->buf+G->pos)); - return 1; - l172:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "AutoLink", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ReferenceLink(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "ReferenceLink")); - { int yypos176= G->pos, yythunkpos176= G->thunkpos; if (!yy_ReferenceLinkDouble(G)) { goto l177; } goto l176; - l177:; G->pos= yypos176; G->thunkpos= yythunkpos176; if (!yy_ReferenceLinkSingle(G)) { goto l175; } - } - l176:; - yyprintf((stderr, " ok %s @ %s\n", "ReferenceLink", G->buf+G->pos)); - return 1; - l175:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ReferenceLink", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ExplicitLink(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 2, 0); - yyprintf((stderr, "%s\n", "ExplicitLink")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l178; if (!yy_Label(G)) { goto l178; } yyDo(G, yySet, -2, 0); if (!yy_Spnl(G)) { goto l178; } if (!yymatchChar(G, '(')) goto l178; if (!yy_Sp(G)) { goto l178; } if (!yy_Source(G)) { goto l178; } yyDo(G, yySet, -1, 0); if (!yy_Spnl(G)) { goto l178; } if (!yy_Title(G)) { goto l178; } if (!yy_Sp(G)) { goto l178; } if (!yymatchChar(G, ')')) goto l178; yyText(G, G->begin, G->end); if (!(YY_END)) goto l178; yyDo(G, yy_1_ExplicitLink, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "ExplicitLink", G->buf+G->pos)); yyDo(G, yyPop, 2, 0); - return 1; - l178:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ExplicitLink", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_StrongUl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "StrongUl")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l179; if (!yy_LocMarker(G)) { goto l179; } yyDo(G, yySet, -1, 0); if (!yymatchString(G, "__")) goto l179; - { int yypos180= G->pos, yythunkpos180= G->thunkpos; if (!yy_Whitespace(G)) { goto l180; } goto l179; - l180:; G->pos= yypos180; G->thunkpos= yythunkpos180; - } - { int yypos183= G->pos, yythunkpos183= G->thunkpos; if (!yymatchString(G, "__")) goto l183; goto l179; - l183:; G->pos= yypos183; G->thunkpos= yythunkpos183; - } if (!yy_Inline(G)) { goto l179; } - l181:; - { int yypos182= G->pos, yythunkpos182= G->thunkpos; - { int yypos184= G->pos, yythunkpos184= G->thunkpos; if (!yymatchString(G, "__")) goto l184; goto l182; - l184:; G->pos= yypos184; G->thunkpos= yythunkpos184; - } if (!yy_Inline(G)) { goto l182; } goto l181; - l182:; G->pos= yypos182; G->thunkpos= yythunkpos182; - } if (!yymatchString(G, "__")) goto l179; yyText(G, G->begin, G->end); if (!(YY_END)) goto l179; yyDo(G, yy_1_StrongUl, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "StrongUl", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l179:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "StrongUl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_StrongStar(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "StrongStar")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l185; if (!yy_LocMarker(G)) { goto l185; } yyDo(G, yySet, -1, 0); if (!yymatchString(G, "**")) goto l185; - { int yypos186= G->pos, yythunkpos186= G->thunkpos; if (!yy_Whitespace(G)) { goto l186; } goto l185; - l186:; G->pos= yypos186; G->thunkpos= yythunkpos186; - } - { int yypos189= G->pos, yythunkpos189= G->thunkpos; if (!yymatchString(G, "**")) goto l189; goto l185; - l189:; G->pos= yypos189; G->thunkpos= yythunkpos189; - } if (!yy_Inline(G)) { goto l185; } - l187:; - { int yypos188= G->pos, yythunkpos188= G->thunkpos; - { int yypos190= G->pos, yythunkpos190= G->thunkpos; if (!yymatchString(G, "**")) goto l190; goto l188; - l190:; G->pos= yypos190; G->thunkpos= yythunkpos190; - } if (!yy_Inline(G)) { goto l188; } goto l187; - l188:; G->pos= yypos188; G->thunkpos= yythunkpos188; - } if (!yymatchString(G, "**")) goto l185; yyText(G, G->begin, G->end); if (!(YY_END)) goto l185; yyDo(G, yy_1_StrongStar, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "StrongStar", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l185:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "StrongStar", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Whitespace(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Whitespace")); - { int yypos192= G->pos, yythunkpos192= G->thunkpos; if (!yy_Spacechar(G)) { goto l193; } goto l192; - l193:; G->pos= yypos192; G->thunkpos= yythunkpos192; if (!yy_Newline(G)) { goto l191; } - } - l192:; - yyprintf((stderr, " ok %s @ %s\n", "Whitespace", G->buf+G->pos)); - return 1; - l191:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Whitespace", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_EmphUl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "EmphUl")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l194; if (!yy_LocMarker(G)) { goto l194; } yyDo(G, yySet, -1, 0); if (!yymatchChar(G, '_')) goto l194; - { int yypos195= G->pos, yythunkpos195= G->thunkpos; if (!yy_Whitespace(G)) { goto l195; } goto l194; - l195:; G->pos= yypos195; G->thunkpos= yythunkpos195; - } - { int yypos198= G->pos, yythunkpos198= G->thunkpos; - { int yypos200= G->pos, yythunkpos200= G->thunkpos; if (!yymatchChar(G, '_')) goto l200; goto l199; - l200:; G->pos= yypos200; G->thunkpos= yythunkpos200; - } if (!yy_Inline(G)) { goto l199; } goto l198; - l199:; G->pos= yypos198; G->thunkpos= yythunkpos198; if (!yy_StrongUl(G)) { goto l194; } - } - l198:; - l196:; - { int yypos197= G->pos, yythunkpos197= G->thunkpos; - { int yypos201= G->pos, yythunkpos201= G->thunkpos; - { int yypos203= G->pos, yythunkpos203= G->thunkpos; if (!yymatchChar(G, '_')) goto l203; goto l202; - l203:; G->pos= yypos203; G->thunkpos= yythunkpos203; - } if (!yy_Inline(G)) { goto l202; } goto l201; - l202:; G->pos= yypos201; G->thunkpos= yythunkpos201; if (!yy_StrongUl(G)) { goto l197; } - } - l201:; goto l196; - l197:; G->pos= yypos197; G->thunkpos= yythunkpos197; - } if (!yymatchChar(G, '_')) goto l194; yyText(G, G->begin, G->end); if (!(YY_END)) goto l194; yyDo(G, yy_1_EmphUl, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "EmphUl", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l194:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "EmphUl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_EmphStar(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "EmphStar")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l204; if (!yy_LocMarker(G)) { goto l204; } yyDo(G, yySet, -1, 0); if (!yymatchChar(G, '*')) goto l204; - { int yypos205= G->pos, yythunkpos205= G->thunkpos; if (!yy_Whitespace(G)) { goto l205; } goto l204; - l205:; G->pos= yypos205; G->thunkpos= yythunkpos205; - } - { int yypos208= G->pos, yythunkpos208= G->thunkpos; - { int yypos210= G->pos, yythunkpos210= G->thunkpos; if (!yymatchChar(G, '*')) goto l210; goto l209; - l210:; G->pos= yypos210; G->thunkpos= yythunkpos210; - } if (!yy_Inline(G)) { goto l209; } goto l208; - l209:; G->pos= yypos208; G->thunkpos= yythunkpos208; if (!yy_StrongStar(G)) { goto l204; } - } - l208:; - l206:; - { int yypos207= G->pos, yythunkpos207= G->thunkpos; - { int yypos211= G->pos, yythunkpos211= G->thunkpos; - { int yypos213= G->pos, yythunkpos213= G->thunkpos; if (!yymatchChar(G, '*')) goto l213; goto l212; - l213:; G->pos= yypos213; G->thunkpos= yythunkpos213; - } if (!yy_Inline(G)) { goto l212; } goto l211; - l212:; G->pos= yypos211; G->thunkpos= yythunkpos211; if (!yy_StrongStar(G)) { goto l207; } - } - l211:; goto l206; - l207:; G->pos= yypos207; G->thunkpos= yythunkpos207; - } if (!yymatchChar(G, '*')) goto l204; yyText(G, G->begin, G->end); if (!(YY_END)) goto l204; yyDo(G, yy_1_EmphStar, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "EmphStar", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l204:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "EmphStar", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_StarLine(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "StarLine")); - { int yypos215= G->pos, yythunkpos215= G->thunkpos; if (!yymatchString(G, "****")) goto l216; - l217:; - { int yypos218= G->pos, yythunkpos218= G->thunkpos; if (!yymatchChar(G, '*')) goto l218; goto l217; - l218:; G->pos= yypos218; G->thunkpos= yythunkpos218; - } goto l215; - l216:; G->pos= yypos215; G->thunkpos= yythunkpos215; if (!yy_Spacechar(G)) { goto l214; } if (!yymatchChar(G, '*')) goto l214; - l219:; - { int yypos220= G->pos, yythunkpos220= G->thunkpos; if (!yymatchChar(G, '*')) goto l220; goto l219; - l220:; G->pos= yypos220; G->thunkpos= yythunkpos220; - } - { int yypos221= G->pos, yythunkpos221= G->thunkpos; if (!yy_Spacechar(G)) { goto l214; } G->pos= yypos221; G->thunkpos= yythunkpos221; - } - } - l215:; - yyprintf((stderr, " ok %s @ %s\n", "StarLine", G->buf+G->pos)); - return 1; - l214:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "StarLine", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_UlLine(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "UlLine")); - { int yypos223= G->pos, yythunkpos223= G->thunkpos; if (!yymatchString(G, "____")) goto l224; - l225:; - { int yypos226= G->pos, yythunkpos226= G->thunkpos; if (!yymatchChar(G, '_')) goto l226; goto l225; - l226:; G->pos= yypos226; G->thunkpos= yythunkpos226; - } goto l223; - l224:; G->pos= yypos223; G->thunkpos= yythunkpos223; if (!yy_Spacechar(G)) { goto l222; } if (!yymatchChar(G, '_')) goto l222; - l227:; - { int yypos228= G->pos, yythunkpos228= G->thunkpos; if (!yymatchChar(G, '_')) goto l228; goto l227; - l228:; G->pos= yypos228; G->thunkpos= yythunkpos228; - } - { int yypos229= G->pos, yythunkpos229= G->thunkpos; if (!yy_Spacechar(G)) { goto l222; } G->pos= yypos229; G->thunkpos= yythunkpos229; - } - } - l223:; - yyprintf((stderr, " ok %s @ %s\n", "UlLine", G->buf+G->pos)); - return 1; - l222:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "UlLine", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_SpecialChar(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "SpecialChar")); - { int yypos231= G->pos, yythunkpos231= G->thunkpos; if (!yymatchChar(G, '$')) goto l232; goto l231; - l232:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '*')) goto l233; goto l231; - l233:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '_')) goto l234; goto l231; - l234:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '`')) goto l235; goto l231; - l235:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '&')) goto l236; goto l231; - l236:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '[')) goto l237; goto l231; - l237:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, ']')) goto l238; goto l231; - l238:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '(')) goto l239; goto l231; - l239:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, ')')) goto l240; goto l231; - l240:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '<')) goto l241; goto l231; - l241:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '!')) goto l242; goto l231; - l242:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '#')) goto l243; goto l231; - l243:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '\\')) goto l244; goto l231; - l244:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '\'')) goto l245; goto l231; - l245:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '"')) goto l246; goto l231; - l246:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yymatchChar(G, '~')) goto l247; goto l231; - l247:; G->pos= yypos231; G->thunkpos= yythunkpos231; if (!yy_ExtendedSpecialChar(G)) { goto l230; } - } - l231:; - yyprintf((stderr, " ok %s @ %s\n", "SpecialChar", G->buf+G->pos)); - return 1; - l230:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SpecialChar", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Eof(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Eof")); - { int yypos249= G->pos, yythunkpos249= G->thunkpos; if (!yymatchDot(G)) goto l249; goto l248; - l249:; G->pos= yypos249; G->thunkpos= yythunkpos249; - } - yyprintf((stderr, " ok %s @ %s\n", "Eof", G->buf+G->pos)); - return 1; - l248:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Eof", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_NormalEndline(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "NormalEndline")); if (!yy_Sp(G)) { goto l250; } if (!yy_Newline(G)) { goto l250; } - { int yypos251= G->pos, yythunkpos251= G->thunkpos; if (!yy_BlankLine(G)) { goto l251; } goto l250; - l251:; G->pos= yypos251; G->thunkpos= yythunkpos251; - } - { int yypos252= G->pos, yythunkpos252= G->thunkpos; if (!yymatchChar(G, '>')) goto l252; goto l250; - l252:; G->pos= yypos252; G->thunkpos= yythunkpos252; - } - { int yypos253= G->pos, yythunkpos253= G->thunkpos; if (!yy_AtxStart(G)) { goto l253; } goto l250; - l253:; G->pos= yypos253; G->thunkpos= yythunkpos253; - } - { int yypos254= G->pos, yythunkpos254= G->thunkpos; if (!yy_Line(G)) { goto l254; } - { int yypos255= G->pos, yythunkpos255= G->thunkpos; if (!yymatchString(G, "===")) goto l256; - l257:; - { int yypos258= G->pos, yythunkpos258= G->thunkpos; if (!yymatchChar(G, '=')) goto l258; goto l257; - l258:; G->pos= yypos258; G->thunkpos= yythunkpos258; - } goto l255; - l256:; G->pos= yypos255; G->thunkpos= yythunkpos255; if (!yymatchString(G, "----")) goto l254; - l259:; - { int yypos260= G->pos, yythunkpos260= G->thunkpos; if (!yymatchChar(G, '-')) goto l260; goto l259; - l260:; G->pos= yypos260; G->thunkpos= yythunkpos260; - } - } - l255:; if (!yy_Newline(G)) { goto l254; } goto l250; - l254:; G->pos= yypos254; G->thunkpos= yythunkpos254; - } - yyprintf((stderr, " ok %s @ %s\n", "NormalEndline", G->buf+G->pos)); - return 1; - l250:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NormalEndline", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_TerminalEndline(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "TerminalEndline")); if (!yy_Sp(G)) { goto l261; } if (!yy_Newline(G)) { goto l261; } if (!yy_Eof(G)) { goto l261; } - yyprintf((stderr, " ok %s @ %s\n", "TerminalEndline", G->buf+G->pos)); - return 1; - l261:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "TerminalEndline", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_LineBreak(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "LineBreak")); if (!yymatchString(G, " ")) goto l262; if (!yy_NormalEndline(G)) { goto l262; } - yyprintf((stderr, " ok %s @ %s\n", "LineBreak", G->buf+G->pos)); - return 1; - l262:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "LineBreak", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_CharEntity(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "CharEntity")); if (!yymatchChar(G, '&')) goto l263; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\377\003\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l263; - l264:; - { int yypos265= G->pos, yythunkpos265= G->thunkpos; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\377\003\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l265; goto l264; - l265:; G->pos= yypos265; G->thunkpos= yythunkpos265; - } if (!yymatchChar(G, ';')) goto l263; - yyprintf((stderr, " ok %s @ %s\n", "CharEntity", G->buf+G->pos)); - return 1; - l263:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "CharEntity", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_DecEntity(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "DecEntity")); if (!yymatchChar(G, '&')) goto l266; if (!yymatchChar(G, '#')) goto l266; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l266; - l267:; - { int yypos268= G->pos, yythunkpos268= G->thunkpos; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l268; goto l267; - l268:; G->pos= yypos268; G->thunkpos= yythunkpos268; - } if (!yymatchChar(G, ';')) goto l266; - yyprintf((stderr, " ok %s @ %s\n", "DecEntity", G->buf+G->pos)); - return 1; - l266:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "DecEntity", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HexEntity(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HexEntity")); if (!yymatchChar(G, '&')) goto l269; if (!yymatchChar(G, '#')) goto l269; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l269; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\377\003\176\000\000\000\176\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l269; - l270:; - { int yypos271= G->pos, yythunkpos271= G->thunkpos; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\377\003\176\000\000\000\176\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l271; goto l270; - l271:; G->pos= yypos271; G->thunkpos= yythunkpos271; - } if (!yymatchChar(G, ';')) goto l269; - yyprintf((stderr, " ok %s @ %s\n", "HexEntity", G->buf+G->pos)); - return 1; - l269:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HexEntity", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Alphanumeric(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Alphanumeric")); - { int yypos273= G->pos, yythunkpos273= G->thunkpos; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\377\003\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l274; goto l273; - l274:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\200")) goto l275; goto l273; - l275:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\201")) goto l276; goto l273; - l276:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\202")) goto l277; goto l273; - l277:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\203")) goto l278; goto l273; - l278:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\204")) goto l279; goto l273; - l279:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\205")) goto l280; goto l273; - l280:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\206")) goto l281; goto l273; - l281:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\207")) goto l282; goto l273; - l282:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\210")) goto l283; goto l273; - l283:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\211")) goto l284; goto l273; - l284:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\212")) goto l285; goto l273; - l285:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\213")) goto l286; goto l273; - l286:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\214")) goto l287; goto l273; - l287:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\215")) goto l288; goto l273; - l288:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\216")) goto l289; goto l273; - l289:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\217")) goto l290; goto l273; - l290:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\220")) goto l291; goto l273; - l291:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\221")) goto l292; goto l273; - l292:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\222")) goto l293; goto l273; - l293:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\223")) goto l294; goto l273; - l294:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\224")) goto l295; goto l273; - l295:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\225")) goto l296; goto l273; - l296:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\226")) goto l297; goto l273; - l297:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\227")) goto l298; goto l273; - l298:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\230")) goto l299; goto l273; - l299:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\231")) goto l300; goto l273; - l300:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\232")) goto l301; goto l273; - l301:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\233")) goto l302; goto l273; - l302:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\234")) goto l303; goto l273; - l303:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\235")) goto l304; goto l273; - l304:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\236")) goto l305; goto l273; - l305:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\237")) goto l306; goto l273; - l306:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\240")) goto l307; goto l273; - l307:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\241")) goto l308; goto l273; - l308:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\242")) goto l309; goto l273; - l309:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\243")) goto l310; goto l273; - l310:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\244")) goto l311; goto l273; - l311:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\245")) goto l312; goto l273; - l312:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\246")) goto l313; goto l273; - l313:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\247")) goto l314; goto l273; - l314:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\250")) goto l315; goto l273; - l315:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\251")) goto l316; goto l273; - l316:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\252")) goto l317; goto l273; - l317:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\253")) goto l318; goto l273; - l318:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\254")) goto l319; goto l273; - l319:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\255")) goto l320; goto l273; - l320:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\256")) goto l321; goto l273; - l321:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\257")) goto l322; goto l273; - l322:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\260")) goto l323; goto l273; - l323:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\261")) goto l324; goto l273; - l324:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\262")) goto l325; goto l273; - l325:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\263")) goto l326; goto l273; - l326:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\264")) goto l327; goto l273; - l327:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\265")) goto l328; goto l273; - l328:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\266")) goto l329; goto l273; - l329:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\267")) goto l330; goto l273; - l330:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\270")) goto l331; goto l273; - l331:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\271")) goto l332; goto l273; - l332:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\272")) goto l333; goto l273; - l333:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\273")) goto l334; goto l273; - l334:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\274")) goto l335; goto l273; - l335:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\275")) goto l336; goto l273; - l336:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\276")) goto l337; goto l273; - l337:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\277")) goto l338; goto l273; - l338:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\300")) goto l339; goto l273; - l339:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\301")) goto l340; goto l273; - l340:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\302")) goto l341; goto l273; - l341:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\303")) goto l342; goto l273; - l342:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\304")) goto l343; goto l273; - l343:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\305")) goto l344; goto l273; - l344:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\306")) goto l345; goto l273; - l345:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\307")) goto l346; goto l273; - l346:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\310")) goto l347; goto l273; - l347:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\311")) goto l348; goto l273; - l348:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\312")) goto l349; goto l273; - l349:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\313")) goto l350; goto l273; - l350:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\314")) goto l351; goto l273; - l351:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\315")) goto l352; goto l273; - l352:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\316")) goto l353; goto l273; - l353:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\317")) goto l354; goto l273; - l354:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\320")) goto l355; goto l273; - l355:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\321")) goto l356; goto l273; - l356:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\322")) goto l357; goto l273; - l357:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\323")) goto l358; goto l273; - l358:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\324")) goto l359; goto l273; - l359:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\325")) goto l360; goto l273; - l360:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\326")) goto l361; goto l273; - l361:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\327")) goto l362; goto l273; - l362:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\330")) goto l363; goto l273; - l363:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\331")) goto l364; goto l273; - l364:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\332")) goto l365; goto l273; - l365:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\333")) goto l366; goto l273; - l366:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\334")) goto l367; goto l273; - l367:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\335")) goto l368; goto l273; - l368:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\336")) goto l369; goto l273; - l369:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\337")) goto l370; goto l273; - l370:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\340")) goto l371; goto l273; - l371:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\341")) goto l372; goto l273; - l372:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\342")) goto l373; goto l273; - l373:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\343")) goto l374; goto l273; - l374:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\344")) goto l375; goto l273; - l375:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\345")) goto l376; goto l273; - l376:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\346")) goto l377; goto l273; - l377:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\347")) goto l378; goto l273; - l378:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\350")) goto l379; goto l273; - l379:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\351")) goto l380; goto l273; - l380:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\352")) goto l381; goto l273; - l381:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\353")) goto l382; goto l273; - l382:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\354")) goto l383; goto l273; - l383:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\355")) goto l384; goto l273; - l384:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\356")) goto l385; goto l273; - l385:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\357")) goto l386; goto l273; - l386:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\360")) goto l387; goto l273; - l387:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\361")) goto l388; goto l273; - l388:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\362")) goto l389; goto l273; - l389:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\363")) goto l390; goto l273; - l390:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\364")) goto l391; goto l273; - l391:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\365")) goto l392; goto l273; - l392:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\366")) goto l393; goto l273; - l393:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\367")) goto l394; goto l273; - l394:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\370")) goto l395; goto l273; - l395:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\371")) goto l396; goto l273; - l396:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\372")) goto l397; goto l273; - l397:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\373")) goto l398; goto l273; - l398:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\374")) goto l399; goto l273; - l399:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\375")) goto l400; goto l273; - l400:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\376")) goto l401; goto l273; - l401:; G->pos= yypos273; G->thunkpos= yythunkpos273; if (!yymatchString(G, "\377")) goto l272; - } - l273:; - yyprintf((stderr, " ok %s @ %s\n", "Alphanumeric", G->buf+G->pos)); - return 1; - l272:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Alphanumeric", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_NormalChar(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "NormalChar")); - { int yypos403= G->pos, yythunkpos403= G->thunkpos; - { int yypos404= G->pos, yythunkpos404= G->thunkpos; if (!yy_SpecialChar(G)) { goto l405; } goto l404; - l405:; G->pos= yypos404; G->thunkpos= yythunkpos404; if (!yy_Spacechar(G)) { goto l406; } goto l404; - l406:; G->pos= yypos404; G->thunkpos= yythunkpos404; if (!yy_Newline(G)) { goto l403; } - } - l404:; goto l402; - l403:; G->pos= yypos403; G->thunkpos= yythunkpos403; - } if (!yymatchDot(G)) goto l402; - yyprintf((stderr, " ok %s @ %s\n", "NormalChar", G->buf+G->pos)); - return 1; - l402:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NormalChar", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Symbol(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Symbol")); if (!yy_SpecialChar(G)) { goto l407; } - yyprintf((stderr, " ok %s @ %s\n", "Symbol", G->buf+G->pos)); - return 1; - l407:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Symbol", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_EscapedChar(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "EscapedChar")); if (!yymatchChar(G, '\\')) goto l408; - { int yypos409= G->pos, yythunkpos409= G->thunkpos; if (!yy_Newline(G)) { goto l409; } goto l408; - l409:; G->pos= yypos409; G->thunkpos= yythunkpos409; - } if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\032\157\000\120\000\000\000\270\001\000\000\170\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l408; - yyprintf((stderr, " ok %s @ %s\n", "EscapedChar", G->buf+G->pos)); - return 1; - l408:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "EscapedChar", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Entity(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "Entity")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l410; if (!yy_LocMarker(G)) { goto l410; } yyDo(G, yySet, -1, 0); - { int yypos411= G->pos, yythunkpos411= G->thunkpos; if (!yy_HexEntity(G)) { goto l412; } goto l411; - l412:; G->pos= yypos411; G->thunkpos= yythunkpos411; if (!yy_DecEntity(G)) { goto l413; } goto l411; - l413:; G->pos= yypos411; G->thunkpos= yythunkpos411; if (!yy_CharEntity(G)) { goto l410; } - } - l411:; yyText(G, G->begin, G->end); if (!(YY_END)) goto l410; yyDo(G, yy_1_Entity, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Entity", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l410:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Entity", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_RawHtml(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "RawHtml")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l414; if (!yy_LocMarker(G)) { goto l414; } yyDo(G, yySet, -1, 0); - { int yypos415= G->pos, yythunkpos415= G->thunkpos; if (!yy_HtmlComment(G)) { goto l416; } goto l415; - l416:; G->pos= yypos415; G->thunkpos= yythunkpos415; if (!yy_HtmlBlockScript(G)) { goto l417; } goto l415; - l417:; G->pos= yypos415; G->thunkpos= yythunkpos415; if (!yy_HtmlTag(G)) { goto l414; } - } - l415:; yyText(G, G->begin, G->end); if (!(YY_END)) goto l414; yyDo(G, yy_1_RawHtml, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "RawHtml", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l414:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "RawHtml", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Code(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "Code")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l418; - { int yypos419= G->pos, yythunkpos419= G->thunkpos; if (!yy_Ticks1(G)) { goto l420; } yyDo(G, yySet, -1, 0); if (!yy_Sp(G)) { goto l420; } - { int yypos423= G->pos, yythunkpos423= G->thunkpos; - { int yypos427= G->pos, yythunkpos427= G->thunkpos; if (!yymatchChar(G, '`')) goto l427; goto l424; - l427:; G->pos= yypos427; G->thunkpos= yythunkpos427; - } if (!yy_Nonspacechar(G)) { goto l424; } - l425:; - { int yypos426= G->pos, yythunkpos426= G->thunkpos; - { int yypos428= G->pos, yythunkpos428= G->thunkpos; if (!yymatchChar(G, '`')) goto l428; goto l426; - l428:; G->pos= yypos428; G->thunkpos= yythunkpos428; - } if (!yy_Nonspacechar(G)) { goto l426; } goto l425; - l426:; G->pos= yypos426; G->thunkpos= yythunkpos426; - } goto l423; - l424:; G->pos= yypos423; G->thunkpos= yythunkpos423; - { int yypos430= G->pos, yythunkpos430= G->thunkpos; if (!yy_Ticks1(G)) { goto l430; } goto l429; - l430:; G->pos= yypos430; G->thunkpos= yythunkpos430; - } if (!yymatchChar(G, '`')) goto l429; - l431:; - { int yypos432= G->pos, yythunkpos432= G->thunkpos; if (!yymatchChar(G, '`')) goto l432; goto l431; - l432:; G->pos= yypos432; G->thunkpos= yythunkpos432; - } goto l423; - l429:; G->pos= yypos423; G->thunkpos= yythunkpos423; - { int yypos433= G->pos, yythunkpos433= G->thunkpos; if (!yy_Sp(G)) { goto l433; } if (!yy_Ticks1(G)) { goto l433; } goto l420; - l433:; G->pos= yypos433; G->thunkpos= yythunkpos433; - } - { int yypos434= G->pos, yythunkpos434= G->thunkpos; if (!yy_Spacechar(G)) { goto l435; } goto l434; - l435:; G->pos= yypos434; G->thunkpos= yythunkpos434; if (!yy_Newline(G)) { goto l420; } - { int yypos436= G->pos, yythunkpos436= G->thunkpos; if (!yy_BlankLine(G)) { goto l436; } goto l420; - l436:; G->pos= yypos436; G->thunkpos= yythunkpos436; - } - } - l434:; - } - l423:; - l421:; - { int yypos422= G->pos, yythunkpos422= G->thunkpos; - { int yypos437= G->pos, yythunkpos437= G->thunkpos; - { int yypos441= G->pos, yythunkpos441= G->thunkpos; if (!yymatchChar(G, '`')) goto l441; goto l438; - l441:; G->pos= yypos441; G->thunkpos= yythunkpos441; - } if (!yy_Nonspacechar(G)) { goto l438; } - l439:; - { int yypos440= G->pos, yythunkpos440= G->thunkpos; - { int yypos442= G->pos, yythunkpos442= G->thunkpos; if (!yymatchChar(G, '`')) goto l442; goto l440; - l442:; G->pos= yypos442; G->thunkpos= yythunkpos442; - } if (!yy_Nonspacechar(G)) { goto l440; } goto l439; - l440:; G->pos= yypos440; G->thunkpos= yythunkpos440; - } goto l437; - l438:; G->pos= yypos437; G->thunkpos= yythunkpos437; - { int yypos444= G->pos, yythunkpos444= G->thunkpos; if (!yy_Ticks1(G)) { goto l444; } goto l443; - l444:; G->pos= yypos444; G->thunkpos= yythunkpos444; - } if (!yymatchChar(G, '`')) goto l443; - l445:; - { int yypos446= G->pos, yythunkpos446= G->thunkpos; if (!yymatchChar(G, '`')) goto l446; goto l445; - l446:; G->pos= yypos446; G->thunkpos= yythunkpos446; - } goto l437; - l443:; G->pos= yypos437; G->thunkpos= yythunkpos437; - { int yypos447= G->pos, yythunkpos447= G->thunkpos; if (!yy_Sp(G)) { goto l447; } if (!yy_Ticks1(G)) { goto l447; } goto l422; - l447:; G->pos= yypos447; G->thunkpos= yythunkpos447; - } - { int yypos448= G->pos, yythunkpos448= G->thunkpos; if (!yy_Spacechar(G)) { goto l449; } goto l448; - l449:; G->pos= yypos448; G->thunkpos= yythunkpos448; if (!yy_Newline(G)) { goto l422; } - { int yypos450= G->pos, yythunkpos450= G->thunkpos; if (!yy_BlankLine(G)) { goto l450; } goto l422; - l450:; G->pos= yypos450; G->thunkpos= yythunkpos450; - } - } - l448:; - } - l437:; goto l421; - l422:; G->pos= yypos422; G->thunkpos= yythunkpos422; - } if (!yy_Sp(G)) { goto l420; } if (!yy_Ticks1(G)) { goto l420; } goto l419; - l420:; G->pos= yypos419; G->thunkpos= yythunkpos419; if (!yy_Ticks2(G)) { goto l451; } yyDo(G, yySet, -1, 0); if (!yy_Sp(G)) { goto l451; } - { int yypos454= G->pos, yythunkpos454= G->thunkpos; - { int yypos458= G->pos, yythunkpos458= G->thunkpos; if (!yymatchChar(G, '`')) goto l458; goto l455; - l458:; G->pos= yypos458; G->thunkpos= yythunkpos458; - } if (!yy_Nonspacechar(G)) { goto l455; } - l456:; - { int yypos457= G->pos, yythunkpos457= G->thunkpos; - { int yypos459= G->pos, yythunkpos459= G->thunkpos; if (!yymatchChar(G, '`')) goto l459; goto l457; - l459:; G->pos= yypos459; G->thunkpos= yythunkpos459; - } if (!yy_Nonspacechar(G)) { goto l457; } goto l456; - l457:; G->pos= yypos457; G->thunkpos= yythunkpos457; - } goto l454; - l455:; G->pos= yypos454; G->thunkpos= yythunkpos454; - { int yypos461= G->pos, yythunkpos461= G->thunkpos; if (!yy_Ticks2(G)) { goto l461; } goto l460; - l461:; G->pos= yypos461; G->thunkpos= yythunkpos461; - } if (!yymatchChar(G, '`')) goto l460; - l462:; - { int yypos463= G->pos, yythunkpos463= G->thunkpos; if (!yymatchChar(G, '`')) goto l463; goto l462; - l463:; G->pos= yypos463; G->thunkpos= yythunkpos463; - } goto l454; - l460:; G->pos= yypos454; G->thunkpos= yythunkpos454; - { int yypos464= G->pos, yythunkpos464= G->thunkpos; if (!yy_Sp(G)) { goto l464; } if (!yy_Ticks2(G)) { goto l464; } goto l451; - l464:; G->pos= yypos464; G->thunkpos= yythunkpos464; - } - { int yypos465= G->pos, yythunkpos465= G->thunkpos; if (!yy_Spacechar(G)) { goto l466; } goto l465; - l466:; G->pos= yypos465; G->thunkpos= yythunkpos465; if (!yy_Newline(G)) { goto l451; } - { int yypos467= G->pos, yythunkpos467= G->thunkpos; if (!yy_BlankLine(G)) { goto l467; } goto l451; - l467:; G->pos= yypos467; G->thunkpos= yythunkpos467; - } - } - l465:; - } - l454:; - l452:; - { int yypos453= G->pos, yythunkpos453= G->thunkpos; - { int yypos468= G->pos, yythunkpos468= G->thunkpos; - { int yypos472= G->pos, yythunkpos472= G->thunkpos; if (!yymatchChar(G, '`')) goto l472; goto l469; - l472:; G->pos= yypos472; G->thunkpos= yythunkpos472; - } if (!yy_Nonspacechar(G)) { goto l469; } - l470:; - { int yypos471= G->pos, yythunkpos471= G->thunkpos; - { int yypos473= G->pos, yythunkpos473= G->thunkpos; if (!yymatchChar(G, '`')) goto l473; goto l471; - l473:; G->pos= yypos473; G->thunkpos= yythunkpos473; - } if (!yy_Nonspacechar(G)) { goto l471; } goto l470; - l471:; G->pos= yypos471; G->thunkpos= yythunkpos471; - } goto l468; - l469:; G->pos= yypos468; G->thunkpos= yythunkpos468; - { int yypos475= G->pos, yythunkpos475= G->thunkpos; if (!yy_Ticks2(G)) { goto l475; } goto l474; - l475:; G->pos= yypos475; G->thunkpos= yythunkpos475; - } if (!yymatchChar(G, '`')) goto l474; - l476:; - { int yypos477= G->pos, yythunkpos477= G->thunkpos; if (!yymatchChar(G, '`')) goto l477; goto l476; - l477:; G->pos= yypos477; G->thunkpos= yythunkpos477; - } goto l468; - l474:; G->pos= yypos468; G->thunkpos= yythunkpos468; - { int yypos478= G->pos, yythunkpos478= G->thunkpos; if (!yy_Sp(G)) { goto l478; } if (!yy_Ticks2(G)) { goto l478; } goto l453; - l478:; G->pos= yypos478; G->thunkpos= yythunkpos478; - } - { int yypos479= G->pos, yythunkpos479= G->thunkpos; if (!yy_Spacechar(G)) { goto l480; } goto l479; - l480:; G->pos= yypos479; G->thunkpos= yythunkpos479; if (!yy_Newline(G)) { goto l453; } - { int yypos481= G->pos, yythunkpos481= G->thunkpos; if (!yy_BlankLine(G)) { goto l481; } goto l453; - l481:; G->pos= yypos481; G->thunkpos= yythunkpos481; - } - } - l479:; - } - l468:; goto l452; - l453:; G->pos= yypos453; G->thunkpos= yythunkpos453; - } if (!yy_Sp(G)) { goto l451; } if (!yy_Ticks2(G)) { goto l451; } goto l419; - l451:; G->pos= yypos419; G->thunkpos= yythunkpos419; if (!yy_Ticks3(G)) { goto l482; } yyDo(G, yySet, -1, 0); if (!yy_Sp(G)) { goto l482; } - { int yypos485= G->pos, yythunkpos485= G->thunkpos; - { int yypos489= G->pos, yythunkpos489= G->thunkpos; if (!yymatchChar(G, '`')) goto l489; goto l486; - l489:; G->pos= yypos489; G->thunkpos= yythunkpos489; - } if (!yy_Nonspacechar(G)) { goto l486; } - l487:; - { int yypos488= G->pos, yythunkpos488= G->thunkpos; - { int yypos490= G->pos, yythunkpos490= G->thunkpos; if (!yymatchChar(G, '`')) goto l490; goto l488; - l490:; G->pos= yypos490; G->thunkpos= yythunkpos490; - } if (!yy_Nonspacechar(G)) { goto l488; } goto l487; - l488:; G->pos= yypos488; G->thunkpos= yythunkpos488; - } goto l485; - l486:; G->pos= yypos485; G->thunkpos= yythunkpos485; - { int yypos492= G->pos, yythunkpos492= G->thunkpos; if (!yy_Ticks3(G)) { goto l492; } goto l491; - l492:; G->pos= yypos492; G->thunkpos= yythunkpos492; - } if (!yymatchChar(G, '`')) goto l491; - l493:; - { int yypos494= G->pos, yythunkpos494= G->thunkpos; if (!yymatchChar(G, '`')) goto l494; goto l493; - l494:; G->pos= yypos494; G->thunkpos= yythunkpos494; - } goto l485; - l491:; G->pos= yypos485; G->thunkpos= yythunkpos485; - { int yypos495= G->pos, yythunkpos495= G->thunkpos; if (!yy_Sp(G)) { goto l495; } if (!yy_Ticks3(G)) { goto l495; } goto l482; - l495:; G->pos= yypos495; G->thunkpos= yythunkpos495; - } - { int yypos496= G->pos, yythunkpos496= G->thunkpos; if (!yy_Spacechar(G)) { goto l497; } goto l496; - l497:; G->pos= yypos496; G->thunkpos= yythunkpos496; if (!yy_Newline(G)) { goto l482; } - } - l496:; - } - l485:; - l483:; - { int yypos484= G->pos, yythunkpos484= G->thunkpos; - { int yypos498= G->pos, yythunkpos498= G->thunkpos; - { int yypos502= G->pos, yythunkpos502= G->thunkpos; if (!yymatchChar(G, '`')) goto l502; goto l499; - l502:; G->pos= yypos502; G->thunkpos= yythunkpos502; - } if (!yy_Nonspacechar(G)) { goto l499; } - l500:; - { int yypos501= G->pos, yythunkpos501= G->thunkpos; - { int yypos503= G->pos, yythunkpos503= G->thunkpos; if (!yymatchChar(G, '`')) goto l503; goto l501; - l503:; G->pos= yypos503; G->thunkpos= yythunkpos503; - } if (!yy_Nonspacechar(G)) { goto l501; } goto l500; - l501:; G->pos= yypos501; G->thunkpos= yythunkpos501; - } goto l498; - l499:; G->pos= yypos498; G->thunkpos= yythunkpos498; - { int yypos505= G->pos, yythunkpos505= G->thunkpos; if (!yy_Ticks3(G)) { goto l505; } goto l504; - l505:; G->pos= yypos505; G->thunkpos= yythunkpos505; - } if (!yymatchChar(G, '`')) goto l504; - l506:; - { int yypos507= G->pos, yythunkpos507= G->thunkpos; if (!yymatchChar(G, '`')) goto l507; goto l506; - l507:; G->pos= yypos507; G->thunkpos= yythunkpos507; - } goto l498; - l504:; G->pos= yypos498; G->thunkpos= yythunkpos498; - { int yypos508= G->pos, yythunkpos508= G->thunkpos; if (!yy_Sp(G)) { goto l508; } if (!yy_Ticks3(G)) { goto l508; } goto l484; - l508:; G->pos= yypos508; G->thunkpos= yythunkpos508; - } - { int yypos509= G->pos, yythunkpos509= G->thunkpos; if (!yy_Spacechar(G)) { goto l510; } goto l509; - l510:; G->pos= yypos509; G->thunkpos= yythunkpos509; if (!yy_Newline(G)) { goto l484; } - } - l509:; - } - l498:; goto l483; - l484:; G->pos= yypos484; G->thunkpos= yythunkpos484; - } if (!yy_Sp(G)) { goto l482; } if (!yy_Ticks3(G)) { goto l482; } goto l419; - l482:; G->pos= yypos419; G->thunkpos= yythunkpos419; if (!yy_Ticks4(G)) { goto l511; } yyDo(G, yySet, -1, 0); if (!yy_Sp(G)) { goto l511; } - { int yypos514= G->pos, yythunkpos514= G->thunkpos; - { int yypos518= G->pos, yythunkpos518= G->thunkpos; if (!yymatchChar(G, '`')) goto l518; goto l515; - l518:; G->pos= yypos518; G->thunkpos= yythunkpos518; - } if (!yy_Nonspacechar(G)) { goto l515; } - l516:; - { int yypos517= G->pos, yythunkpos517= G->thunkpos; - { int yypos519= G->pos, yythunkpos519= G->thunkpos; if (!yymatchChar(G, '`')) goto l519; goto l517; - l519:; G->pos= yypos519; G->thunkpos= yythunkpos519; - } if (!yy_Nonspacechar(G)) { goto l517; } goto l516; - l517:; G->pos= yypos517; G->thunkpos= yythunkpos517; - } goto l514; - l515:; G->pos= yypos514; G->thunkpos= yythunkpos514; - { int yypos521= G->pos, yythunkpos521= G->thunkpos; if (!yy_Ticks4(G)) { goto l521; } goto l520; - l521:; G->pos= yypos521; G->thunkpos= yythunkpos521; - } if (!yymatchChar(G, '`')) goto l520; - l522:; - { int yypos523= G->pos, yythunkpos523= G->thunkpos; if (!yymatchChar(G, '`')) goto l523; goto l522; - l523:; G->pos= yypos523; G->thunkpos= yythunkpos523; - } goto l514; - l520:; G->pos= yypos514; G->thunkpos= yythunkpos514; - { int yypos524= G->pos, yythunkpos524= G->thunkpos; if (!yy_Sp(G)) { goto l524; } if (!yy_Ticks4(G)) { goto l524; } goto l511; - l524:; G->pos= yypos524; G->thunkpos= yythunkpos524; - } - { int yypos525= G->pos, yythunkpos525= G->thunkpos; if (!yy_Spacechar(G)) { goto l526; } goto l525; - l526:; G->pos= yypos525; G->thunkpos= yythunkpos525; if (!yy_Newline(G)) { goto l511; } - { int yypos527= G->pos, yythunkpos527= G->thunkpos; if (!yy_BlankLine(G)) { goto l527; } goto l511; - l527:; G->pos= yypos527; G->thunkpos= yythunkpos527; - } - } - l525:; - } - l514:; - l512:; - { int yypos513= G->pos, yythunkpos513= G->thunkpos; - { int yypos528= G->pos, yythunkpos528= G->thunkpos; - { int yypos532= G->pos, yythunkpos532= G->thunkpos; if (!yymatchChar(G, '`')) goto l532; goto l529; - l532:; G->pos= yypos532; G->thunkpos= yythunkpos532; - } if (!yy_Nonspacechar(G)) { goto l529; } - l530:; - { int yypos531= G->pos, yythunkpos531= G->thunkpos; - { int yypos533= G->pos, yythunkpos533= G->thunkpos; if (!yymatchChar(G, '`')) goto l533; goto l531; - l533:; G->pos= yypos533; G->thunkpos= yythunkpos533; - } if (!yy_Nonspacechar(G)) { goto l531; } goto l530; - l531:; G->pos= yypos531; G->thunkpos= yythunkpos531; - } goto l528; - l529:; G->pos= yypos528; G->thunkpos= yythunkpos528; - { int yypos535= G->pos, yythunkpos535= G->thunkpos; if (!yy_Ticks4(G)) { goto l535; } goto l534; - l535:; G->pos= yypos535; G->thunkpos= yythunkpos535; - } if (!yymatchChar(G, '`')) goto l534; - l536:; - { int yypos537= G->pos, yythunkpos537= G->thunkpos; if (!yymatchChar(G, '`')) goto l537; goto l536; - l537:; G->pos= yypos537; G->thunkpos= yythunkpos537; - } goto l528; - l534:; G->pos= yypos528; G->thunkpos= yythunkpos528; - { int yypos538= G->pos, yythunkpos538= G->thunkpos; if (!yy_Sp(G)) { goto l538; } if (!yy_Ticks4(G)) { goto l538; } goto l513; - l538:; G->pos= yypos538; G->thunkpos= yythunkpos538; - } - { int yypos539= G->pos, yythunkpos539= G->thunkpos; if (!yy_Spacechar(G)) { goto l540; } goto l539; - l540:; G->pos= yypos539; G->thunkpos= yythunkpos539; if (!yy_Newline(G)) { goto l513; } - { int yypos541= G->pos, yythunkpos541= G->thunkpos; if (!yy_BlankLine(G)) { goto l541; } goto l513; - l541:; G->pos= yypos541; G->thunkpos= yythunkpos541; - } - } - l539:; - } - l528:; goto l512; - l513:; G->pos= yypos513; G->thunkpos= yythunkpos513; - } if (!yy_Sp(G)) { goto l511; } if (!yy_Ticks4(G)) { goto l511; } goto l419; - l511:; G->pos= yypos419; G->thunkpos= yythunkpos419; if (!yy_Ticks5(G)) { goto l542; } yyDo(G, yySet, -1, 0); if (!yy_Sp(G)) { goto l542; } - { int yypos545= G->pos, yythunkpos545= G->thunkpos; - { int yypos549= G->pos, yythunkpos549= G->thunkpos; if (!yymatchChar(G, '`')) goto l549; goto l546; - l549:; G->pos= yypos549; G->thunkpos= yythunkpos549; - } if (!yy_Nonspacechar(G)) { goto l546; } - l547:; - { int yypos548= G->pos, yythunkpos548= G->thunkpos; - { int yypos550= G->pos, yythunkpos550= G->thunkpos; if (!yymatchChar(G, '`')) goto l550; goto l548; - l550:; G->pos= yypos550; G->thunkpos= yythunkpos550; - } if (!yy_Nonspacechar(G)) { goto l548; } goto l547; - l548:; G->pos= yypos548; G->thunkpos= yythunkpos548; - } goto l545; - l546:; G->pos= yypos545; G->thunkpos= yythunkpos545; - { int yypos552= G->pos, yythunkpos552= G->thunkpos; if (!yy_Ticks5(G)) { goto l552; } goto l551; - l552:; G->pos= yypos552; G->thunkpos= yythunkpos552; - } if (!yymatchChar(G, '`')) goto l551; - l553:; - { int yypos554= G->pos, yythunkpos554= G->thunkpos; if (!yymatchChar(G, '`')) goto l554; goto l553; - l554:; G->pos= yypos554; G->thunkpos= yythunkpos554; - } goto l545; - l551:; G->pos= yypos545; G->thunkpos= yythunkpos545; - { int yypos555= G->pos, yythunkpos555= G->thunkpos; if (!yy_Sp(G)) { goto l555; } if (!yy_Ticks5(G)) { goto l555; } goto l542; - l555:; G->pos= yypos555; G->thunkpos= yythunkpos555; - } - { int yypos556= G->pos, yythunkpos556= G->thunkpos; if (!yy_Spacechar(G)) { goto l557; } goto l556; - l557:; G->pos= yypos556; G->thunkpos= yythunkpos556; if (!yy_Newline(G)) { goto l542; } - { int yypos558= G->pos, yythunkpos558= G->thunkpos; if (!yy_BlankLine(G)) { goto l558; } goto l542; - l558:; G->pos= yypos558; G->thunkpos= yythunkpos558; - } - } - l556:; - } - l545:; - l543:; - { int yypos544= G->pos, yythunkpos544= G->thunkpos; - { int yypos559= G->pos, yythunkpos559= G->thunkpos; - { int yypos563= G->pos, yythunkpos563= G->thunkpos; if (!yymatchChar(G, '`')) goto l563; goto l560; - l563:; G->pos= yypos563; G->thunkpos= yythunkpos563; - } if (!yy_Nonspacechar(G)) { goto l560; } - l561:; - { int yypos562= G->pos, yythunkpos562= G->thunkpos; - { int yypos564= G->pos, yythunkpos564= G->thunkpos; if (!yymatchChar(G, '`')) goto l564; goto l562; - l564:; G->pos= yypos564; G->thunkpos= yythunkpos564; - } if (!yy_Nonspacechar(G)) { goto l562; } goto l561; - l562:; G->pos= yypos562; G->thunkpos= yythunkpos562; - } goto l559; - l560:; G->pos= yypos559; G->thunkpos= yythunkpos559; - { int yypos566= G->pos, yythunkpos566= G->thunkpos; if (!yy_Ticks5(G)) { goto l566; } goto l565; - l566:; G->pos= yypos566; G->thunkpos= yythunkpos566; - } if (!yymatchChar(G, '`')) goto l565; - l567:; - { int yypos568= G->pos, yythunkpos568= G->thunkpos; if (!yymatchChar(G, '`')) goto l568; goto l567; - l568:; G->pos= yypos568; G->thunkpos= yythunkpos568; - } goto l559; - l565:; G->pos= yypos559; G->thunkpos= yythunkpos559; - { int yypos569= G->pos, yythunkpos569= G->thunkpos; if (!yy_Sp(G)) { goto l569; } if (!yy_Ticks5(G)) { goto l569; } goto l544; - l569:; G->pos= yypos569; G->thunkpos= yythunkpos569; - } - { int yypos570= G->pos, yythunkpos570= G->thunkpos; if (!yy_Spacechar(G)) { goto l571; } goto l570; - l571:; G->pos= yypos570; G->thunkpos= yythunkpos570; if (!yy_Newline(G)) { goto l544; } - { int yypos572= G->pos, yythunkpos572= G->thunkpos; if (!yy_BlankLine(G)) { goto l572; } goto l544; - l572:; G->pos= yypos572; G->thunkpos= yythunkpos572; - } - } - l570:; - } - l559:; goto l543; - l544:; G->pos= yypos544; G->thunkpos= yythunkpos544; - } if (!yy_Sp(G)) { goto l542; } if (!yy_Ticks5(G)) { goto l542; } goto l419; - l542:; G->pos= yypos419; G->thunkpos= yythunkpos419; if (!yy_Waves3(G)) { goto l573; } yyDo(G, yySet, -1, 0); if (!yy_Sp(G)) { goto l573; } - { int yypos576= G->pos, yythunkpos576= G->thunkpos; - { int yypos580= G->pos, yythunkpos580= G->thunkpos; if (!yymatchChar(G, '~')) goto l580; goto l577; - l580:; G->pos= yypos580; G->thunkpos= yythunkpos580; - } if (!yy_Nonspacechar(G)) { goto l577; } - l578:; - { int yypos579= G->pos, yythunkpos579= G->thunkpos; - { int yypos581= G->pos, yythunkpos581= G->thunkpos; if (!yymatchChar(G, '~')) goto l581; goto l579; - l581:; G->pos= yypos581; G->thunkpos= yythunkpos581; - } if (!yy_Nonspacechar(G)) { goto l579; } goto l578; - l579:; G->pos= yypos579; G->thunkpos= yythunkpos579; - } goto l576; - l577:; G->pos= yypos576; G->thunkpos= yythunkpos576; - { int yypos583= G->pos, yythunkpos583= G->thunkpos; if (!yy_Waves3(G)) { goto l583; } goto l582; - l583:; G->pos= yypos583; G->thunkpos= yythunkpos583; - } if (!yymatchChar(G, '~')) goto l582; - l584:; - { int yypos585= G->pos, yythunkpos585= G->thunkpos; if (!yymatchChar(G, '~')) goto l585; goto l584; - l585:; G->pos= yypos585; G->thunkpos= yythunkpos585; - } goto l576; - l582:; G->pos= yypos576; G->thunkpos= yythunkpos576; - { int yypos586= G->pos, yythunkpos586= G->thunkpos; if (!yy_Sp(G)) { goto l586; } if (!yy_Waves3(G)) { goto l586; } goto l573; - l586:; G->pos= yypos586; G->thunkpos= yythunkpos586; - } - { int yypos587= G->pos, yythunkpos587= G->thunkpos; if (!yy_Spacechar(G)) { goto l588; } goto l587; - l588:; G->pos= yypos587; G->thunkpos= yythunkpos587; if (!yy_Newline(G)) { goto l573; } - } - l587:; - } - l576:; - l574:; - { int yypos575= G->pos, yythunkpos575= G->thunkpos; - { int yypos589= G->pos, yythunkpos589= G->thunkpos; - { int yypos593= G->pos, yythunkpos593= G->thunkpos; if (!yymatchChar(G, '~')) goto l593; goto l590; - l593:; G->pos= yypos593; G->thunkpos= yythunkpos593; - } if (!yy_Nonspacechar(G)) { goto l590; } - l591:; - { int yypos592= G->pos, yythunkpos592= G->thunkpos; - { int yypos594= G->pos, yythunkpos594= G->thunkpos; if (!yymatchChar(G, '~')) goto l594; goto l592; - l594:; G->pos= yypos594; G->thunkpos= yythunkpos594; - } if (!yy_Nonspacechar(G)) { goto l592; } goto l591; - l592:; G->pos= yypos592; G->thunkpos= yythunkpos592; - } goto l589; - l590:; G->pos= yypos589; G->thunkpos= yythunkpos589; - { int yypos596= G->pos, yythunkpos596= G->thunkpos; if (!yy_Waves3(G)) { goto l596; } goto l595; - l596:; G->pos= yypos596; G->thunkpos= yythunkpos596; - } if (!yymatchChar(G, '~')) goto l595; - l597:; - { int yypos598= G->pos, yythunkpos598= G->thunkpos; if (!yymatchChar(G, '~')) goto l598; goto l597; - l598:; G->pos= yypos598; G->thunkpos= yythunkpos598; - } goto l589; - l595:; G->pos= yypos589; G->thunkpos= yythunkpos589; - { int yypos599= G->pos, yythunkpos599= G->thunkpos; if (!yy_Sp(G)) { goto l599; } if (!yy_Waves3(G)) { goto l599; } goto l575; - l599:; G->pos= yypos599; G->thunkpos= yythunkpos599; - } - { int yypos600= G->pos, yythunkpos600= G->thunkpos; if (!yy_Spacechar(G)) { goto l601; } goto l600; - l601:; G->pos= yypos600; G->thunkpos= yythunkpos600; if (!yy_Newline(G)) { goto l575; } - } - l600:; - } - l589:; goto l574; - l575:; G->pos= yypos575; G->thunkpos= yythunkpos575; - } if (!yy_Sp(G)) { goto l573; } if (!yy_Waves3(G)) { goto l573; } goto l419; - l573:; G->pos= yypos419; G->thunkpos= yythunkpos419; if (!yy_Waves4(G)) { goto l602; } yyDo(G, yySet, -1, 0); if (!yy_Sp(G)) { goto l602; } - { int yypos605= G->pos, yythunkpos605= G->thunkpos; - { int yypos609= G->pos, yythunkpos609= G->thunkpos; if (!yymatchChar(G, '~')) goto l609; goto l606; - l609:; G->pos= yypos609; G->thunkpos= yythunkpos609; - } if (!yy_Nonspacechar(G)) { goto l606; } - l607:; - { int yypos608= G->pos, yythunkpos608= G->thunkpos; - { int yypos610= G->pos, yythunkpos610= G->thunkpos; if (!yymatchChar(G, '~')) goto l610; goto l608; - l610:; G->pos= yypos610; G->thunkpos= yythunkpos610; - } if (!yy_Nonspacechar(G)) { goto l608; } goto l607; - l608:; G->pos= yypos608; G->thunkpos= yythunkpos608; - } goto l605; - l606:; G->pos= yypos605; G->thunkpos= yythunkpos605; - { int yypos612= G->pos, yythunkpos612= G->thunkpos; if (!yy_Waves4(G)) { goto l612; } goto l611; - l612:; G->pos= yypos612; G->thunkpos= yythunkpos612; - } if (!yymatchChar(G, '~')) goto l611; - l613:; - { int yypos614= G->pos, yythunkpos614= G->thunkpos; if (!yymatchChar(G, '~')) goto l614; goto l613; - l614:; G->pos= yypos614; G->thunkpos= yythunkpos614; - } goto l605; - l611:; G->pos= yypos605; G->thunkpos= yythunkpos605; - { int yypos615= G->pos, yythunkpos615= G->thunkpos; if (!yy_Sp(G)) { goto l615; } if (!yy_Waves4(G)) { goto l615; } goto l602; - l615:; G->pos= yypos615; G->thunkpos= yythunkpos615; - } - { int yypos616= G->pos, yythunkpos616= G->thunkpos; if (!yy_Spacechar(G)) { goto l617; } goto l616; - l617:; G->pos= yypos616; G->thunkpos= yythunkpos616; if (!yy_Newline(G)) { goto l602; } - { int yypos618= G->pos, yythunkpos618= G->thunkpos; if (!yy_BlankLine(G)) { goto l618; } goto l602; - l618:; G->pos= yypos618; G->thunkpos= yythunkpos618; - } - } - l616:; - } - l605:; - l603:; - { int yypos604= G->pos, yythunkpos604= G->thunkpos; - { int yypos619= G->pos, yythunkpos619= G->thunkpos; - { int yypos623= G->pos, yythunkpos623= G->thunkpos; if (!yymatchChar(G, '~')) goto l623; goto l620; - l623:; G->pos= yypos623; G->thunkpos= yythunkpos623; - } if (!yy_Nonspacechar(G)) { goto l620; } - l621:; - { int yypos622= G->pos, yythunkpos622= G->thunkpos; - { int yypos624= G->pos, yythunkpos624= G->thunkpos; if (!yymatchChar(G, '~')) goto l624; goto l622; - l624:; G->pos= yypos624; G->thunkpos= yythunkpos624; - } if (!yy_Nonspacechar(G)) { goto l622; } goto l621; - l622:; G->pos= yypos622; G->thunkpos= yythunkpos622; - } goto l619; - l620:; G->pos= yypos619; G->thunkpos= yythunkpos619; - { int yypos626= G->pos, yythunkpos626= G->thunkpos; if (!yy_Waves4(G)) { goto l626; } goto l625; - l626:; G->pos= yypos626; G->thunkpos= yythunkpos626; - } if (!yymatchChar(G, '~')) goto l625; - l627:; - { int yypos628= G->pos, yythunkpos628= G->thunkpos; if (!yymatchChar(G, '~')) goto l628; goto l627; - l628:; G->pos= yypos628; G->thunkpos= yythunkpos628; - } goto l619; - l625:; G->pos= yypos619; G->thunkpos= yythunkpos619; - { int yypos629= G->pos, yythunkpos629= G->thunkpos; if (!yy_Sp(G)) { goto l629; } if (!yy_Waves4(G)) { goto l629; } goto l604; - l629:; G->pos= yypos629; G->thunkpos= yythunkpos629; - } - { int yypos630= G->pos, yythunkpos630= G->thunkpos; if (!yy_Spacechar(G)) { goto l631; } goto l630; - l631:; G->pos= yypos630; G->thunkpos= yythunkpos630; if (!yy_Newline(G)) { goto l604; } - { int yypos632= G->pos, yythunkpos632= G->thunkpos; if (!yy_BlankLine(G)) { goto l632; } goto l604; - l632:; G->pos= yypos632; G->thunkpos= yythunkpos632; - } - } - l630:; - } - l619:; goto l603; - l604:; G->pos= yypos604; G->thunkpos= yythunkpos604; - } if (!yy_Sp(G)) { goto l602; } if (!yy_Waves4(G)) { goto l602; } goto l419; - l602:; G->pos= yypos419; G->thunkpos= yythunkpos419; if (!yy_Waves5(G)) { goto l418; } yyDo(G, yySet, -1, 0); if (!yy_Sp(G)) { goto l418; } - { int yypos635= G->pos, yythunkpos635= G->thunkpos; - { int yypos639= G->pos, yythunkpos639= G->thunkpos; if (!yymatchChar(G, '~')) goto l639; goto l636; - l639:; G->pos= yypos639; G->thunkpos= yythunkpos639; - } if (!yy_Nonspacechar(G)) { goto l636; } - l637:; - { int yypos638= G->pos, yythunkpos638= G->thunkpos; - { int yypos640= G->pos, yythunkpos640= G->thunkpos; if (!yymatchChar(G, '~')) goto l640; goto l638; - l640:; G->pos= yypos640; G->thunkpos= yythunkpos640; - } if (!yy_Nonspacechar(G)) { goto l638; } goto l637; - l638:; G->pos= yypos638; G->thunkpos= yythunkpos638; - } goto l635; - l636:; G->pos= yypos635; G->thunkpos= yythunkpos635; - { int yypos642= G->pos, yythunkpos642= G->thunkpos; if (!yy_Waves5(G)) { goto l642; } goto l641; - l642:; G->pos= yypos642; G->thunkpos= yythunkpos642; - } if (!yymatchChar(G, '~')) goto l641; - l643:; - { int yypos644= G->pos, yythunkpos644= G->thunkpos; if (!yymatchChar(G, '~')) goto l644; goto l643; - l644:; G->pos= yypos644; G->thunkpos= yythunkpos644; - } goto l635; - l641:; G->pos= yypos635; G->thunkpos= yythunkpos635; - { int yypos645= G->pos, yythunkpos645= G->thunkpos; if (!yy_Sp(G)) { goto l645; } if (!yy_Waves5(G)) { goto l645; } goto l418; - l645:; G->pos= yypos645; G->thunkpos= yythunkpos645; - } - { int yypos646= G->pos, yythunkpos646= G->thunkpos; if (!yy_Spacechar(G)) { goto l647; } goto l646; - l647:; G->pos= yypos646; G->thunkpos= yythunkpos646; if (!yy_Newline(G)) { goto l418; } - { int yypos648= G->pos, yythunkpos648= G->thunkpos; if (!yy_BlankLine(G)) { goto l648; } goto l418; - l648:; G->pos= yypos648; G->thunkpos= yythunkpos648; - } - } - l646:; - } - l635:; - l633:; - { int yypos634= G->pos, yythunkpos634= G->thunkpos; - { int yypos649= G->pos, yythunkpos649= G->thunkpos; - { int yypos653= G->pos, yythunkpos653= G->thunkpos; if (!yymatchChar(G, '~')) goto l653; goto l650; - l653:; G->pos= yypos653; G->thunkpos= yythunkpos653; - } if (!yy_Nonspacechar(G)) { goto l650; } - l651:; - { int yypos652= G->pos, yythunkpos652= G->thunkpos; - { int yypos654= G->pos, yythunkpos654= G->thunkpos; if (!yymatchChar(G, '~')) goto l654; goto l652; - l654:; G->pos= yypos654; G->thunkpos= yythunkpos654; - } if (!yy_Nonspacechar(G)) { goto l652; } goto l651; - l652:; G->pos= yypos652; G->thunkpos= yythunkpos652; - } goto l649; - l650:; G->pos= yypos649; G->thunkpos= yythunkpos649; - { int yypos656= G->pos, yythunkpos656= G->thunkpos; if (!yy_Waves5(G)) { goto l656; } goto l655; - l656:; G->pos= yypos656; G->thunkpos= yythunkpos656; - } if (!yymatchChar(G, '~')) goto l655; - l657:; - { int yypos658= G->pos, yythunkpos658= G->thunkpos; if (!yymatchChar(G, '~')) goto l658; goto l657; - l658:; G->pos= yypos658; G->thunkpos= yythunkpos658; - } goto l649; - l655:; G->pos= yypos649; G->thunkpos= yythunkpos649; - { int yypos659= G->pos, yythunkpos659= G->thunkpos; if (!yy_Sp(G)) { goto l659; } if (!yy_Waves5(G)) { goto l659; } goto l634; - l659:; G->pos= yypos659; G->thunkpos= yythunkpos659; - } - { int yypos660= G->pos, yythunkpos660= G->thunkpos; if (!yy_Spacechar(G)) { goto l661; } goto l660; - l661:; G->pos= yypos660; G->thunkpos= yythunkpos660; if (!yy_Newline(G)) { goto l634; } - { int yypos662= G->pos, yythunkpos662= G->thunkpos; if (!yy_BlankLine(G)) { goto l662; } goto l634; - l662:; G->pos= yypos662; G->thunkpos= yythunkpos662; - } - } - l660:; - } - l649:; goto l633; - l634:; G->pos= yypos634; G->thunkpos= yythunkpos634; - } if (!yy_Sp(G)) { goto l418; } if (!yy_Waves5(G)) { goto l418; } - } - l419:; yyText(G, G->begin, G->end); if (!(YY_END)) goto l418; yyDo(G, yy_1_Code, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Code", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l418:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Code", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_InlineNote(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "InlineNote")); yyText(G, G->begin, G->end); if (!( EXT(pmh_EXT_NOTES) )) goto l663; if (!yymatchString(G, "^[")) goto l663; - { int yypos666= G->pos, yythunkpos666= G->thunkpos; if (!yymatchChar(G, ']')) goto l666; goto l663; - l666:; G->pos= yypos666; G->thunkpos= yythunkpos666; - } if (!yy_Inline(G)) { goto l663; } - l664:; - { int yypos665= G->pos, yythunkpos665= G->thunkpos; - { int yypos667= G->pos, yythunkpos667= G->thunkpos; if (!yymatchChar(G, ']')) goto l667; goto l665; - l667:; G->pos= yypos667; G->thunkpos= yythunkpos667; - } if (!yy_Inline(G)) { goto l665; } goto l664; - l665:; G->pos= yypos665; G->thunkpos= yythunkpos665; - } if (!yymatchChar(G, ']')) goto l663; - yyprintf((stderr, " ok %s @ %s\n", "InlineNote", G->buf+G->pos)); - return 1; - l663:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "InlineNote", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_NoteReference(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "NoteReference")); yyText(G, G->begin, G->end); if (!( EXT(pmh_EXT_NOTES) )) goto l668; if (!yy_RawNoteReference(G)) { goto l668; } - yyprintf((stderr, " ok %s @ %s\n", "NoteReference", G->buf+G->pos)); - return 1; - l668:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NoteReference", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Link(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Link")); - { int yypos670= G->pos, yythunkpos670= G->thunkpos; if (!yy_ExplicitLink(G)) { goto l671; } goto l670; - l671:; G->pos= yypos670; G->thunkpos= yythunkpos670; if (!yy_ReferenceLink(G)) { goto l672; } goto l670; - l672:; G->pos= yypos670; G->thunkpos= yythunkpos670; if (!yy_AutoLink(G)) { goto l669; } - } - l670:; yyDo(G, yy_1_Link, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Link", G->buf+G->pos)); - return 1; - l669:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Link", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Image(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Image")); if (!yymatchChar(G, '!')) goto l673; - { int yypos674= G->pos, yythunkpos674= G->thunkpos; if (!yy_ExplicitLink(G)) { goto l675; } goto l674; - l675:; G->pos= yypos674; G->thunkpos= yythunkpos674; if (!yy_ReferenceLink(G)) { goto l673; } - } - l674:; yyDo(G, yy_1_Image, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Image", G->buf+G->pos)); - return 1; - l673:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Image", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Emph(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Emph")); - { int yypos677= G->pos, yythunkpos677= G->thunkpos; if (!yy_EmphStar(G)) { goto l678; } goto l677; - l678:; G->pos= yypos677; G->thunkpos= yythunkpos677; if (!yy_EmphUl(G)) { goto l676; } - } - l677:; - yyprintf((stderr, " ok %s @ %s\n", "Emph", G->buf+G->pos)); - return 1; - l676:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Emph", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Strong(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Strong")); - { int yypos680= G->pos, yythunkpos680= G->thunkpos; if (!yy_StrongStar(G)) { goto l681; } goto l680; - l681:; G->pos= yypos680; G->thunkpos= yythunkpos680; if (!yy_StrongUl(G)) { goto l679; } - } - l680:; - yyprintf((stderr, " ok %s @ %s\n", "Strong", G->buf+G->pos)); - return 1; - l679:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Strong", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Math(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Math")); - { int yypos683= G->pos, yythunkpos683= G->thunkpos; if (!yy_Dollar1Math(G)) { goto l684; } goto l683; - l684:; G->pos= yypos683; G->thunkpos= yythunkpos683; if (!yy_Dollar2Math(G)) { goto l682; } - } - l683:; - yyprintf((stderr, " ok %s @ %s\n", "Math", G->buf+G->pos)); - return 1; - l682:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Math", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Space(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Space")); if (!yy_Spacechar(G)) { goto l685; } - l686:; - { int yypos687= G->pos, yythunkpos687= G->thunkpos; if (!yy_Spacechar(G)) { goto l687; } goto l686; - l687:; G->pos= yypos687; G->thunkpos= yythunkpos687; - } - yyprintf((stderr, " ok %s @ %s\n", "Space", G->buf+G->pos)); - return 1; - l685:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Space", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_UlOrStarLine(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "UlOrStarLine")); - { int yypos689= G->pos, yythunkpos689= G->thunkpos; if (!yy_UlLine(G)) { goto l690; } goto l689; - l690:; G->pos= yypos689; G->thunkpos= yythunkpos689; if (!yy_StarLine(G)) { goto l688; } - } - l689:; - yyprintf((stderr, " ok %s @ %s\n", "UlOrStarLine", G->buf+G->pos)); - return 1; - l688:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "UlOrStarLine", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Str(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Str")); if (!yy_NormalChar(G)) { goto l691; } - l692:; - { int yypos693= G->pos, yythunkpos693= G->thunkpos; - { int yypos694= G->pos, yythunkpos694= G->thunkpos; if (!yy_NormalChar(G)) { goto l695; } goto l694; - l695:; G->pos= yypos694; G->thunkpos= yythunkpos694; if (!yymatchChar(G, '_')) goto l693; - l696:; - { int yypos697= G->pos, yythunkpos697= G->thunkpos; if (!yymatchChar(G, '_')) goto l697; goto l696; - l697:; G->pos= yypos697; G->thunkpos= yythunkpos697; - } - { int yypos698= G->pos, yythunkpos698= G->thunkpos; if (!yy_Alphanumeric(G)) { goto l693; } G->pos= yypos698; G->thunkpos= yythunkpos698; - } - } - l694:; goto l692; - l693:; G->pos= yypos693; G->thunkpos= yythunkpos693; - } - yyprintf((stderr, " ok %s @ %s\n", "Str", G->buf+G->pos)); - return 1; - l691:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Str", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_InStyleTags(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "InStyleTags")); if (!yy_StyleOpen(G)) { goto l699; } - l700:; - { int yypos701= G->pos, yythunkpos701= G->thunkpos; - { int yypos702= G->pos, yythunkpos702= G->thunkpos; if (!yy_StyleClose(G)) { goto l702; } goto l701; - l702:; G->pos= yypos702; G->thunkpos= yythunkpos702; - } if (!yymatchDot(G)) goto l701; goto l700; - l701:; G->pos= yypos701; G->thunkpos= yythunkpos701; - } if (!yy_StyleClose(G)) { goto l699; } - yyprintf((stderr, " ok %s @ %s\n", "InStyleTags", G->buf+G->pos)); - return 1; - l699:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "InStyleTags", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_StyleClose(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "StyleClose")); if (!yymatchChar(G, '<')) goto l703; if (!yy_Spnl(G)) { goto l703; } if (!yymatchChar(G, '/')) goto l703; - { int yypos704= G->pos, yythunkpos704= G->thunkpos; if (!yymatchString(G, "style")) goto l705; goto l704; - l705:; G->pos= yypos704; G->thunkpos= yythunkpos704; if (!yymatchString(G, "STYLE")) goto l703; - } - l704:; if (!yy_Spnl(G)) { goto l703; } if (!yymatchChar(G, '>')) goto l703; - yyprintf((stderr, " ok %s @ %s\n", "StyleClose", G->buf+G->pos)); - return 1; - l703:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "StyleClose", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_StyleOpen(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "StyleOpen")); if (!yymatchChar(G, '<')) goto l706; if (!yy_Spnl(G)) { goto l706; } - { int yypos707= G->pos, yythunkpos707= G->thunkpos; if (!yymatchString(G, "style")) goto l708; goto l707; - l708:; G->pos= yypos707; G->thunkpos= yythunkpos707; if (!yymatchString(G, "STYLE")) goto l706; - } - l707:; if (!yy_Spnl(G)) { goto l706; } - l709:; - { int yypos710= G->pos, yythunkpos710= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l710; } goto l709; - l710:; G->pos= yypos710; G->thunkpos= yythunkpos710; - } if (!yymatchChar(G, '>')) goto l706; - yyprintf((stderr, " ok %s @ %s\n", "StyleOpen", G->buf+G->pos)); - return 1; - l706:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "StyleOpen", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockType(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockType")); - { int yypos712= G->pos, yythunkpos712= G->thunkpos; if (!yymatchString(G, "address")) goto l713; goto l712; - l713:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "blockquote")) goto l714; goto l712; - l714:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "center")) goto l715; goto l712; - l715:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "dir")) goto l716; goto l712; - l716:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "div")) goto l717; goto l712; - l717:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "dl")) goto l718; goto l712; - l718:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "fieldset")) goto l719; goto l712; - l719:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "form")) goto l720; goto l712; - l720:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "h1")) goto l721; goto l712; - l721:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "h2")) goto l722; goto l712; - l722:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "h3")) goto l723; goto l712; - l723:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "h4")) goto l724; goto l712; - l724:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "h5")) goto l725; goto l712; - l725:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "h6")) goto l726; goto l712; - l726:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "hr")) goto l727; goto l712; - l727:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "isindex")) goto l728; goto l712; - l728:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "menu")) goto l729; goto l712; - l729:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "noframes")) goto l730; goto l712; - l730:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "noscript")) goto l731; goto l712; - l731:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "ol")) goto l732; goto l712; - l732:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchChar(G, 'p')) goto l733; goto l712; - l733:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "pre")) goto l734; goto l712; - l734:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "table")) goto l735; goto l712; - l735:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "ul")) goto l736; goto l712; - l736:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "dd")) goto l737; goto l712; - l737:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "dt")) goto l738; goto l712; - l738:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "frameset")) goto l739; goto l712; - l739:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "li")) goto l740; goto l712; - l740:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "tbody")) goto l741; goto l712; - l741:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "td")) goto l742; goto l712; - l742:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "tfoot")) goto l743; goto l712; - l743:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "th")) goto l744; goto l712; - l744:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "thead")) goto l745; goto l712; - l745:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "tr")) goto l746; goto l712; - l746:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "script")) goto l747; goto l712; - l747:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "ADDRESS")) goto l748; goto l712; - l748:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "BLOCKQUOTE")) goto l749; goto l712; - l749:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "CENTER")) goto l750; goto l712; - l750:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "DIR")) goto l751; goto l712; - l751:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "DIV")) goto l752; goto l712; - l752:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "DL")) goto l753; goto l712; - l753:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "FIELDSET")) goto l754; goto l712; - l754:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "FORM")) goto l755; goto l712; - l755:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "H1")) goto l756; goto l712; - l756:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "H2")) goto l757; goto l712; - l757:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "H3")) goto l758; goto l712; - l758:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "H4")) goto l759; goto l712; - l759:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "H5")) goto l760; goto l712; - l760:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "H6")) goto l761; goto l712; - l761:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "HR")) goto l762; goto l712; - l762:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "ISINDEX")) goto l763; goto l712; - l763:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "MENU")) goto l764; goto l712; - l764:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "NOFRAMES")) goto l765; goto l712; - l765:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "NOSCRIPT")) goto l766; goto l712; - l766:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "OL")) goto l767; goto l712; - l767:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchChar(G, 'P')) goto l768; goto l712; - l768:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "PRE")) goto l769; goto l712; - l769:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "TABLE")) goto l770; goto l712; - l770:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "UL")) goto l771; goto l712; - l771:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "DD")) goto l772; goto l712; - l772:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "DT")) goto l773; goto l712; - l773:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "FRAMESET")) goto l774; goto l712; - l774:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "LI")) goto l775; goto l712; - l775:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "TBODY")) goto l776; goto l712; - l776:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "TD")) goto l777; goto l712; - l777:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "TFOOT")) goto l778; goto l712; - l778:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "TH")) goto l779; goto l712; - l779:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "THEAD")) goto l780; goto l712; - l780:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "TR")) goto l781; goto l712; - l781:; G->pos= yypos712; G->thunkpos= yythunkpos712; if (!yymatchString(G, "SCRIPT")) goto l711; - } - l712:; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockType", G->buf+G->pos)); - return 1; - l711:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockType", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockSelfClosing(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockSelfClosing")); if (!yymatchChar(G, '<')) goto l782; if (!yy_Spnl(G)) { goto l782; } if (!yy_HtmlBlockType(G)) { goto l782; } if (!yy_Spnl(G)) { goto l782; } - l783:; - { int yypos784= G->pos, yythunkpos784= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l784; } goto l783; - l784:; G->pos= yypos784; G->thunkpos= yythunkpos784; - } if (!yymatchChar(G, '/')) goto l782; if (!yy_Spnl(G)) { goto l782; } if (!yymatchChar(G, '>')) goto l782; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockSelfClosing", G->buf+G->pos)); - return 1; - l782:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockSelfClosing", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlComment(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "HtmlComment")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l785; if (!yy_LocMarker(G)) { goto l785; } yyDo(G, yySet, -1, 0); if (!yymatchString(G, "")) goto l788; goto l787; - l788:; G->pos= yypos788; G->thunkpos= yythunkpos788; - } if (!yymatchDot(G)) goto l787; goto l786; - l787:; G->pos= yypos787; G->thunkpos= yythunkpos787; - } if (!yymatchString(G, "-->")) goto l785; yyText(G, G->begin, G->end); if (!(YY_END)) goto l785; yyDo(G, yy_1_HtmlComment, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "HtmlComment", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l785:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlComment", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockInTags(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockInTags")); - { int yypos790= G->pos, yythunkpos790= G->thunkpos; if (!yy_HtmlBlockAddress(G)) { goto l791; } goto l790; - l791:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockBlockquote(G)) { goto l792; } goto l790; - l792:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockCenter(G)) { goto l793; } goto l790; - l793:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockDir(G)) { goto l794; } goto l790; - l794:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockDiv(G)) { goto l795; } goto l790; - l795:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockDl(G)) { goto l796; } goto l790; - l796:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockFieldset(G)) { goto l797; } goto l790; - l797:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockForm(G)) { goto l798; } goto l790; - l798:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockH1(G)) { goto l799; } goto l790; - l799:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockH2(G)) { goto l800; } goto l790; - l800:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockH3(G)) { goto l801; } goto l790; - l801:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockH4(G)) { goto l802; } goto l790; - l802:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockH5(G)) { goto l803; } goto l790; - l803:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockH6(G)) { goto l804; } goto l790; - l804:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockMenu(G)) { goto l805; } goto l790; - l805:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockNoframes(G)) { goto l806; } goto l790; - l806:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockNoscript(G)) { goto l807; } goto l790; - l807:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockOl(G)) { goto l808; } goto l790; - l808:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockP(G)) { goto l809; } goto l790; - l809:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockPre(G)) { goto l810; } goto l790; - l810:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockTable(G)) { goto l811; } goto l790; - l811:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockUl(G)) { goto l812; } goto l790; - l812:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockDd(G)) { goto l813; } goto l790; - l813:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockDt(G)) { goto l814; } goto l790; - l814:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockFrameset(G)) { goto l815; } goto l790; - l815:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockLi(G)) { goto l816; } goto l790; - l816:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockTbody(G)) { goto l817; } goto l790; - l817:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockTd(G)) { goto l818; } goto l790; - l818:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockTfoot(G)) { goto l819; } goto l790; - l819:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockTh(G)) { goto l820; } goto l790; - l820:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockThead(G)) { goto l821; } goto l790; - l821:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockTr(G)) { goto l822; } goto l790; - l822:; G->pos= yypos790; G->thunkpos= yythunkpos790; if (!yy_HtmlBlockScript(G)) { goto l789; } - } - l790:; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockInTags", G->buf+G->pos)); - return 1; - l789:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockInTags", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockScript(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockScript")); if (!yy_HtmlBlockOpenScript(G)) { goto l823; } - l824:; - { int yypos825= G->pos, yythunkpos825= G->thunkpos; - { int yypos826= G->pos, yythunkpos826= G->thunkpos; if (!yy_HtmlBlockCloseScript(G)) { goto l826; } goto l825; - l826:; G->pos= yypos826; G->thunkpos= yythunkpos826; - } if (!yymatchDot(G)) goto l825; goto l824; - l825:; G->pos= yypos825; G->thunkpos= yythunkpos825; - } if (!yy_HtmlBlockCloseScript(G)) { goto l823; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockScript", G->buf+G->pos)); - return 1; - l823:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockScript", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseScript(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseScript")); if (!yymatchChar(G, '<')) goto l827; if (!yy_Spnl(G)) { goto l827; } if (!yymatchChar(G, '/')) goto l827; - { int yypos828= G->pos, yythunkpos828= G->thunkpos; if (!yymatchString(G, "script")) goto l829; goto l828; - l829:; G->pos= yypos828; G->thunkpos= yythunkpos828; if (!yymatchString(G, "SCRIPT")) goto l827; - } - l828:; if (!yy_Spnl(G)) { goto l827; } if (!yymatchChar(G, '>')) goto l827; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseScript", G->buf+G->pos)); - return 1; - l827:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseScript", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenScript(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenScript")); if (!yymatchChar(G, '<')) goto l830; if (!yy_Spnl(G)) { goto l830; } - { int yypos831= G->pos, yythunkpos831= G->thunkpos; if (!yymatchString(G, "script")) goto l832; goto l831; - l832:; G->pos= yypos831; G->thunkpos= yythunkpos831; if (!yymatchString(G, "SCRIPT")) goto l830; - } - l831:; if (!yy_Spnl(G)) { goto l830; } - l833:; - { int yypos834= G->pos, yythunkpos834= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l834; } goto l833; - l834:; G->pos= yypos834; G->thunkpos= yythunkpos834; - } if (!yymatchChar(G, '>')) goto l830; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenScript", G->buf+G->pos)); - return 1; - l830:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenScript", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockTr(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockTr")); if (!yy_HtmlBlockOpenTr(G)) { goto l835; } - l836:; - { int yypos837= G->pos, yythunkpos837= G->thunkpos; - { int yypos838= G->pos, yythunkpos838= G->thunkpos; if (!yy_HtmlBlockTr(G)) { goto l839; } goto l838; - l839:; G->pos= yypos838; G->thunkpos= yythunkpos838; - { int yypos840= G->pos, yythunkpos840= G->thunkpos; if (!yy_HtmlBlockCloseTr(G)) { goto l840; } goto l837; - l840:; G->pos= yypos840; G->thunkpos= yythunkpos840; - } if (!yymatchDot(G)) goto l837; - } - l838:; goto l836; - l837:; G->pos= yypos837; G->thunkpos= yythunkpos837; - } if (!yy_HtmlBlockCloseTr(G)) { goto l835; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockTr", G->buf+G->pos)); - return 1; - l835:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockTr", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseTr(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseTr")); if (!yymatchChar(G, '<')) goto l841; if (!yy_Spnl(G)) { goto l841; } if (!yymatchChar(G, '/')) goto l841; - { int yypos842= G->pos, yythunkpos842= G->thunkpos; if (!yymatchString(G, "tr")) goto l843; goto l842; - l843:; G->pos= yypos842; G->thunkpos= yythunkpos842; if (!yymatchString(G, "TR")) goto l841; - } - l842:; if (!yy_Spnl(G)) { goto l841; } if (!yymatchChar(G, '>')) goto l841; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseTr", G->buf+G->pos)); - return 1; - l841:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseTr", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenTr(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenTr")); if (!yymatchChar(G, '<')) goto l844; if (!yy_Spnl(G)) { goto l844; } - { int yypos845= G->pos, yythunkpos845= G->thunkpos; if (!yymatchString(G, "tr")) goto l846; goto l845; - l846:; G->pos= yypos845; G->thunkpos= yythunkpos845; if (!yymatchString(G, "TR")) goto l844; - } - l845:; if (!yy_Spnl(G)) { goto l844; } - l847:; - { int yypos848= G->pos, yythunkpos848= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l848; } goto l847; - l848:; G->pos= yypos848; G->thunkpos= yythunkpos848; - } if (!yymatchChar(G, '>')) goto l844; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenTr", G->buf+G->pos)); - return 1; - l844:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenTr", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockThead(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockThead")); if (!yy_HtmlBlockOpenThead(G)) { goto l849; } - l850:; - { int yypos851= G->pos, yythunkpos851= G->thunkpos; - { int yypos852= G->pos, yythunkpos852= G->thunkpos; if (!yy_HtmlBlockThead(G)) { goto l853; } goto l852; - l853:; G->pos= yypos852; G->thunkpos= yythunkpos852; - { int yypos854= G->pos, yythunkpos854= G->thunkpos; if (!yy_HtmlBlockCloseThead(G)) { goto l854; } goto l851; - l854:; G->pos= yypos854; G->thunkpos= yythunkpos854; - } if (!yymatchDot(G)) goto l851; - } - l852:; goto l850; - l851:; G->pos= yypos851; G->thunkpos= yythunkpos851; - } if (!yy_HtmlBlockCloseThead(G)) { goto l849; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockThead", G->buf+G->pos)); - return 1; - l849:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockThead", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseThead(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseThead")); if (!yymatchChar(G, '<')) goto l855; if (!yy_Spnl(G)) { goto l855; } if (!yymatchChar(G, '/')) goto l855; - { int yypos856= G->pos, yythunkpos856= G->thunkpos; if (!yymatchString(G, "thead")) goto l857; goto l856; - l857:; G->pos= yypos856; G->thunkpos= yythunkpos856; if (!yymatchString(G, "THEAD")) goto l855; - } - l856:; if (!yy_Spnl(G)) { goto l855; } if (!yymatchChar(G, '>')) goto l855; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseThead", G->buf+G->pos)); - return 1; - l855:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseThead", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenThead(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenThead")); if (!yymatchChar(G, '<')) goto l858; if (!yy_Spnl(G)) { goto l858; } - { int yypos859= G->pos, yythunkpos859= G->thunkpos; if (!yymatchString(G, "thead")) goto l860; goto l859; - l860:; G->pos= yypos859; G->thunkpos= yythunkpos859; if (!yymatchString(G, "THEAD")) goto l858; - } - l859:; if (!yy_Spnl(G)) { goto l858; } - l861:; - { int yypos862= G->pos, yythunkpos862= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l862; } goto l861; - l862:; G->pos= yypos862; G->thunkpos= yythunkpos862; - } if (!yymatchChar(G, '>')) goto l858; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenThead", G->buf+G->pos)); - return 1; - l858:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenThead", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockTh(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockTh")); if (!yy_HtmlBlockOpenTh(G)) { goto l863; } - l864:; - { int yypos865= G->pos, yythunkpos865= G->thunkpos; - { int yypos866= G->pos, yythunkpos866= G->thunkpos; if (!yy_HtmlBlockTh(G)) { goto l867; } goto l866; - l867:; G->pos= yypos866; G->thunkpos= yythunkpos866; - { int yypos868= G->pos, yythunkpos868= G->thunkpos; if (!yy_HtmlBlockCloseTh(G)) { goto l868; } goto l865; - l868:; G->pos= yypos868; G->thunkpos= yythunkpos868; - } if (!yymatchDot(G)) goto l865; - } - l866:; goto l864; - l865:; G->pos= yypos865; G->thunkpos= yythunkpos865; - } if (!yy_HtmlBlockCloseTh(G)) { goto l863; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockTh", G->buf+G->pos)); - return 1; - l863:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockTh", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseTh(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseTh")); if (!yymatchChar(G, '<')) goto l869; if (!yy_Spnl(G)) { goto l869; } if (!yymatchChar(G, '/')) goto l869; - { int yypos870= G->pos, yythunkpos870= G->thunkpos; if (!yymatchString(G, "th")) goto l871; goto l870; - l871:; G->pos= yypos870; G->thunkpos= yythunkpos870; if (!yymatchString(G, "TH")) goto l869; - } - l870:; if (!yy_Spnl(G)) { goto l869; } if (!yymatchChar(G, '>')) goto l869; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseTh", G->buf+G->pos)); - return 1; - l869:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseTh", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenTh(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenTh")); if (!yymatchChar(G, '<')) goto l872; if (!yy_Spnl(G)) { goto l872; } - { int yypos873= G->pos, yythunkpos873= G->thunkpos; if (!yymatchString(G, "th")) goto l874; goto l873; - l874:; G->pos= yypos873; G->thunkpos= yythunkpos873; if (!yymatchString(G, "TH")) goto l872; - } - l873:; if (!yy_Spnl(G)) { goto l872; } - l875:; - { int yypos876= G->pos, yythunkpos876= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l876; } goto l875; - l876:; G->pos= yypos876; G->thunkpos= yythunkpos876; - } if (!yymatchChar(G, '>')) goto l872; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenTh", G->buf+G->pos)); - return 1; - l872:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenTh", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockTfoot(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockTfoot")); if (!yy_HtmlBlockOpenTfoot(G)) { goto l877; } - l878:; - { int yypos879= G->pos, yythunkpos879= G->thunkpos; - { int yypos880= G->pos, yythunkpos880= G->thunkpos; if (!yy_HtmlBlockTfoot(G)) { goto l881; } goto l880; - l881:; G->pos= yypos880; G->thunkpos= yythunkpos880; - { int yypos882= G->pos, yythunkpos882= G->thunkpos; if (!yy_HtmlBlockCloseTfoot(G)) { goto l882; } goto l879; - l882:; G->pos= yypos882; G->thunkpos= yythunkpos882; - } if (!yymatchDot(G)) goto l879; - } - l880:; goto l878; - l879:; G->pos= yypos879; G->thunkpos= yythunkpos879; - } if (!yy_HtmlBlockCloseTfoot(G)) { goto l877; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockTfoot", G->buf+G->pos)); - return 1; - l877:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockTfoot", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseTfoot(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseTfoot")); if (!yymatchChar(G, '<')) goto l883; if (!yy_Spnl(G)) { goto l883; } if (!yymatchChar(G, '/')) goto l883; - { int yypos884= G->pos, yythunkpos884= G->thunkpos; if (!yymatchString(G, "tfoot")) goto l885; goto l884; - l885:; G->pos= yypos884; G->thunkpos= yythunkpos884; if (!yymatchString(G, "TFOOT")) goto l883; - } - l884:; if (!yy_Spnl(G)) { goto l883; } if (!yymatchChar(G, '>')) goto l883; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseTfoot", G->buf+G->pos)); - return 1; - l883:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseTfoot", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenTfoot(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenTfoot")); if (!yymatchChar(G, '<')) goto l886; if (!yy_Spnl(G)) { goto l886; } - { int yypos887= G->pos, yythunkpos887= G->thunkpos; if (!yymatchString(G, "tfoot")) goto l888; goto l887; - l888:; G->pos= yypos887; G->thunkpos= yythunkpos887; if (!yymatchString(G, "TFOOT")) goto l886; - } - l887:; if (!yy_Spnl(G)) { goto l886; } - l889:; - { int yypos890= G->pos, yythunkpos890= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l890; } goto l889; - l890:; G->pos= yypos890; G->thunkpos= yythunkpos890; - } if (!yymatchChar(G, '>')) goto l886; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenTfoot", G->buf+G->pos)); - return 1; - l886:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenTfoot", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockTd(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockTd")); if (!yy_HtmlBlockOpenTd(G)) { goto l891; } - l892:; - { int yypos893= G->pos, yythunkpos893= G->thunkpos; - { int yypos894= G->pos, yythunkpos894= G->thunkpos; if (!yy_HtmlBlockTd(G)) { goto l895; } goto l894; - l895:; G->pos= yypos894; G->thunkpos= yythunkpos894; - { int yypos896= G->pos, yythunkpos896= G->thunkpos; if (!yy_HtmlBlockCloseTd(G)) { goto l896; } goto l893; - l896:; G->pos= yypos896; G->thunkpos= yythunkpos896; - } if (!yymatchDot(G)) goto l893; - } - l894:; goto l892; - l893:; G->pos= yypos893; G->thunkpos= yythunkpos893; - } if (!yy_HtmlBlockCloseTd(G)) { goto l891; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockTd", G->buf+G->pos)); - return 1; - l891:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockTd", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseTd(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseTd")); if (!yymatchChar(G, '<')) goto l897; if (!yy_Spnl(G)) { goto l897; } if (!yymatchChar(G, '/')) goto l897; - { int yypos898= G->pos, yythunkpos898= G->thunkpos; if (!yymatchString(G, "td")) goto l899; goto l898; - l899:; G->pos= yypos898; G->thunkpos= yythunkpos898; if (!yymatchString(G, "TD")) goto l897; - } - l898:; if (!yy_Spnl(G)) { goto l897; } if (!yymatchChar(G, '>')) goto l897; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseTd", G->buf+G->pos)); - return 1; - l897:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseTd", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenTd(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenTd")); if (!yymatchChar(G, '<')) goto l900; if (!yy_Spnl(G)) { goto l900; } - { int yypos901= G->pos, yythunkpos901= G->thunkpos; if (!yymatchString(G, "td")) goto l902; goto l901; - l902:; G->pos= yypos901; G->thunkpos= yythunkpos901; if (!yymatchString(G, "TD")) goto l900; - } - l901:; if (!yy_Spnl(G)) { goto l900; } - l903:; - { int yypos904= G->pos, yythunkpos904= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l904; } goto l903; - l904:; G->pos= yypos904; G->thunkpos= yythunkpos904; - } if (!yymatchChar(G, '>')) goto l900; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenTd", G->buf+G->pos)); - return 1; - l900:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenTd", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockTbody(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockTbody")); if (!yy_HtmlBlockOpenTbody(G)) { goto l905; } - l906:; - { int yypos907= G->pos, yythunkpos907= G->thunkpos; - { int yypos908= G->pos, yythunkpos908= G->thunkpos; if (!yy_HtmlBlockTbody(G)) { goto l909; } goto l908; - l909:; G->pos= yypos908; G->thunkpos= yythunkpos908; - { int yypos910= G->pos, yythunkpos910= G->thunkpos; if (!yy_HtmlBlockCloseTbody(G)) { goto l910; } goto l907; - l910:; G->pos= yypos910; G->thunkpos= yythunkpos910; - } if (!yymatchDot(G)) goto l907; - } - l908:; goto l906; - l907:; G->pos= yypos907; G->thunkpos= yythunkpos907; - } if (!yy_HtmlBlockCloseTbody(G)) { goto l905; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockTbody", G->buf+G->pos)); - return 1; - l905:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockTbody", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseTbody(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseTbody")); if (!yymatchChar(G, '<')) goto l911; if (!yy_Spnl(G)) { goto l911; } if (!yymatchChar(G, '/')) goto l911; - { int yypos912= G->pos, yythunkpos912= G->thunkpos; if (!yymatchString(G, "tbody")) goto l913; goto l912; - l913:; G->pos= yypos912; G->thunkpos= yythunkpos912; if (!yymatchString(G, "TBODY")) goto l911; - } - l912:; if (!yy_Spnl(G)) { goto l911; } if (!yymatchChar(G, '>')) goto l911; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseTbody", G->buf+G->pos)); - return 1; - l911:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseTbody", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenTbody(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenTbody")); if (!yymatchChar(G, '<')) goto l914; if (!yy_Spnl(G)) { goto l914; } - { int yypos915= G->pos, yythunkpos915= G->thunkpos; if (!yymatchString(G, "tbody")) goto l916; goto l915; - l916:; G->pos= yypos915; G->thunkpos= yythunkpos915; if (!yymatchString(G, "TBODY")) goto l914; - } - l915:; if (!yy_Spnl(G)) { goto l914; } - l917:; - { int yypos918= G->pos, yythunkpos918= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l918; } goto l917; - l918:; G->pos= yypos918; G->thunkpos= yythunkpos918; - } if (!yymatchChar(G, '>')) goto l914; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenTbody", G->buf+G->pos)); - return 1; - l914:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenTbody", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockLi(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockLi")); if (!yy_HtmlBlockOpenLi(G)) { goto l919; } - l920:; - { int yypos921= G->pos, yythunkpos921= G->thunkpos; - { int yypos922= G->pos, yythunkpos922= G->thunkpos; if (!yy_HtmlBlockLi(G)) { goto l923; } goto l922; - l923:; G->pos= yypos922; G->thunkpos= yythunkpos922; - { int yypos924= G->pos, yythunkpos924= G->thunkpos; if (!yy_HtmlBlockCloseLi(G)) { goto l924; } goto l921; - l924:; G->pos= yypos924; G->thunkpos= yythunkpos924; - } if (!yymatchDot(G)) goto l921; - } - l922:; goto l920; - l921:; G->pos= yypos921; G->thunkpos= yythunkpos921; - } if (!yy_HtmlBlockCloseLi(G)) { goto l919; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockLi", G->buf+G->pos)); - return 1; - l919:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockLi", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseLi(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseLi")); if (!yymatchChar(G, '<')) goto l925; if (!yy_Spnl(G)) { goto l925; } if (!yymatchChar(G, '/')) goto l925; - { int yypos926= G->pos, yythunkpos926= G->thunkpos; if (!yymatchString(G, "li")) goto l927; goto l926; - l927:; G->pos= yypos926; G->thunkpos= yythunkpos926; if (!yymatchString(G, "LI")) goto l925; - } - l926:; if (!yy_Spnl(G)) { goto l925; } if (!yymatchChar(G, '>')) goto l925; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseLi", G->buf+G->pos)); - return 1; - l925:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseLi", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenLi(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenLi")); if (!yymatchChar(G, '<')) goto l928; if (!yy_Spnl(G)) { goto l928; } - { int yypos929= G->pos, yythunkpos929= G->thunkpos; if (!yymatchString(G, "li")) goto l930; goto l929; - l930:; G->pos= yypos929; G->thunkpos= yythunkpos929; if (!yymatchString(G, "LI")) goto l928; - } - l929:; if (!yy_Spnl(G)) { goto l928; } - l931:; - { int yypos932= G->pos, yythunkpos932= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l932; } goto l931; - l932:; G->pos= yypos932; G->thunkpos= yythunkpos932; - } if (!yymatchChar(G, '>')) goto l928; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenLi", G->buf+G->pos)); - return 1; - l928:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenLi", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockFrameset(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockFrameset")); if (!yy_HtmlBlockOpenFrameset(G)) { goto l933; } - l934:; - { int yypos935= G->pos, yythunkpos935= G->thunkpos; - { int yypos936= G->pos, yythunkpos936= G->thunkpos; if (!yy_HtmlBlockFrameset(G)) { goto l937; } goto l936; - l937:; G->pos= yypos936; G->thunkpos= yythunkpos936; - { int yypos938= G->pos, yythunkpos938= G->thunkpos; if (!yy_HtmlBlockCloseFrameset(G)) { goto l938; } goto l935; - l938:; G->pos= yypos938; G->thunkpos= yythunkpos938; - } if (!yymatchDot(G)) goto l935; - } - l936:; goto l934; - l935:; G->pos= yypos935; G->thunkpos= yythunkpos935; - } if (!yy_HtmlBlockCloseFrameset(G)) { goto l933; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockFrameset", G->buf+G->pos)); - return 1; - l933:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockFrameset", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseFrameset(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseFrameset")); if (!yymatchChar(G, '<')) goto l939; if (!yy_Spnl(G)) { goto l939; } if (!yymatchChar(G, '/')) goto l939; - { int yypos940= G->pos, yythunkpos940= G->thunkpos; if (!yymatchString(G, "frameset")) goto l941; goto l940; - l941:; G->pos= yypos940; G->thunkpos= yythunkpos940; if (!yymatchString(G, "FRAMESET")) goto l939; - } - l940:; if (!yy_Spnl(G)) { goto l939; } if (!yymatchChar(G, '>')) goto l939; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseFrameset", G->buf+G->pos)); - return 1; - l939:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseFrameset", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenFrameset(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenFrameset")); if (!yymatchChar(G, '<')) goto l942; if (!yy_Spnl(G)) { goto l942; } - { int yypos943= G->pos, yythunkpos943= G->thunkpos; if (!yymatchString(G, "frameset")) goto l944; goto l943; - l944:; G->pos= yypos943; G->thunkpos= yythunkpos943; if (!yymatchString(G, "FRAMESET")) goto l942; - } - l943:; if (!yy_Spnl(G)) { goto l942; } - l945:; - { int yypos946= G->pos, yythunkpos946= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l946; } goto l945; - l946:; G->pos= yypos946; G->thunkpos= yythunkpos946; - } if (!yymatchChar(G, '>')) goto l942; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenFrameset", G->buf+G->pos)); - return 1; - l942:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenFrameset", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockDt(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockDt")); if (!yy_HtmlBlockOpenDt(G)) { goto l947; } - l948:; - { int yypos949= G->pos, yythunkpos949= G->thunkpos; - { int yypos950= G->pos, yythunkpos950= G->thunkpos; if (!yy_HtmlBlockDt(G)) { goto l951; } goto l950; - l951:; G->pos= yypos950; G->thunkpos= yythunkpos950; - { int yypos952= G->pos, yythunkpos952= G->thunkpos; if (!yy_HtmlBlockCloseDt(G)) { goto l952; } goto l949; - l952:; G->pos= yypos952; G->thunkpos= yythunkpos952; - } if (!yymatchDot(G)) goto l949; - } - l950:; goto l948; - l949:; G->pos= yypos949; G->thunkpos= yythunkpos949; - } if (!yy_HtmlBlockCloseDt(G)) { goto l947; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockDt", G->buf+G->pos)); - return 1; - l947:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockDt", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseDt(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseDt")); if (!yymatchChar(G, '<')) goto l953; if (!yy_Spnl(G)) { goto l953; } if (!yymatchChar(G, '/')) goto l953; - { int yypos954= G->pos, yythunkpos954= G->thunkpos; if (!yymatchString(G, "dt")) goto l955; goto l954; - l955:; G->pos= yypos954; G->thunkpos= yythunkpos954; if (!yymatchString(G, "DT")) goto l953; - } - l954:; if (!yy_Spnl(G)) { goto l953; } if (!yymatchChar(G, '>')) goto l953; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseDt", G->buf+G->pos)); - return 1; - l953:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseDt", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenDt(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenDt")); if (!yymatchChar(G, '<')) goto l956; if (!yy_Spnl(G)) { goto l956; } - { int yypos957= G->pos, yythunkpos957= G->thunkpos; if (!yymatchString(G, "dt")) goto l958; goto l957; - l958:; G->pos= yypos957; G->thunkpos= yythunkpos957; if (!yymatchString(G, "DT")) goto l956; - } - l957:; if (!yy_Spnl(G)) { goto l956; } - l959:; - { int yypos960= G->pos, yythunkpos960= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l960; } goto l959; - l960:; G->pos= yypos960; G->thunkpos= yythunkpos960; - } if (!yymatchChar(G, '>')) goto l956; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenDt", G->buf+G->pos)); - return 1; - l956:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenDt", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockDd(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockDd")); if (!yy_HtmlBlockOpenDd(G)) { goto l961; } - l962:; - { int yypos963= G->pos, yythunkpos963= G->thunkpos; - { int yypos964= G->pos, yythunkpos964= G->thunkpos; if (!yy_HtmlBlockDd(G)) { goto l965; } goto l964; - l965:; G->pos= yypos964; G->thunkpos= yythunkpos964; - { int yypos966= G->pos, yythunkpos966= G->thunkpos; if (!yy_HtmlBlockCloseDd(G)) { goto l966; } goto l963; - l966:; G->pos= yypos966; G->thunkpos= yythunkpos966; - } if (!yymatchDot(G)) goto l963; - } - l964:; goto l962; - l963:; G->pos= yypos963; G->thunkpos= yythunkpos963; - } if (!yy_HtmlBlockCloseDd(G)) { goto l961; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockDd", G->buf+G->pos)); - return 1; - l961:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockDd", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseDd(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseDd")); if (!yymatchChar(G, '<')) goto l967; if (!yy_Spnl(G)) { goto l967; } if (!yymatchChar(G, '/')) goto l967; - { int yypos968= G->pos, yythunkpos968= G->thunkpos; if (!yymatchString(G, "dd")) goto l969; goto l968; - l969:; G->pos= yypos968; G->thunkpos= yythunkpos968; if (!yymatchString(G, "DD")) goto l967; - } - l968:; if (!yy_Spnl(G)) { goto l967; } if (!yymatchChar(G, '>')) goto l967; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseDd", G->buf+G->pos)); - return 1; - l967:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseDd", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenDd(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenDd")); if (!yymatchChar(G, '<')) goto l970; if (!yy_Spnl(G)) { goto l970; } - { int yypos971= G->pos, yythunkpos971= G->thunkpos; if (!yymatchString(G, "dd")) goto l972; goto l971; - l972:; G->pos= yypos971; G->thunkpos= yythunkpos971; if (!yymatchString(G, "DD")) goto l970; - } - l971:; if (!yy_Spnl(G)) { goto l970; } - l973:; - { int yypos974= G->pos, yythunkpos974= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l974; } goto l973; - l974:; G->pos= yypos974; G->thunkpos= yythunkpos974; - } if (!yymatchChar(G, '>')) goto l970; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenDd", G->buf+G->pos)); - return 1; - l970:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenDd", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockUl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockUl")); if (!yy_HtmlBlockOpenUl(G)) { goto l975; } - l976:; - { int yypos977= G->pos, yythunkpos977= G->thunkpos; - { int yypos978= G->pos, yythunkpos978= G->thunkpos; if (!yy_HtmlBlockUl(G)) { goto l979; } goto l978; - l979:; G->pos= yypos978; G->thunkpos= yythunkpos978; - { int yypos980= G->pos, yythunkpos980= G->thunkpos; if (!yy_HtmlBlockCloseUl(G)) { goto l980; } goto l977; - l980:; G->pos= yypos980; G->thunkpos= yythunkpos980; - } if (!yymatchDot(G)) goto l977; - } - l978:; goto l976; - l977:; G->pos= yypos977; G->thunkpos= yythunkpos977; - } if (!yy_HtmlBlockCloseUl(G)) { goto l975; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockUl", G->buf+G->pos)); - return 1; - l975:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockUl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseUl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseUl")); if (!yymatchChar(G, '<')) goto l981; if (!yy_Spnl(G)) { goto l981; } if (!yymatchChar(G, '/')) goto l981; - { int yypos982= G->pos, yythunkpos982= G->thunkpos; if (!yymatchString(G, "ul")) goto l983; goto l982; - l983:; G->pos= yypos982; G->thunkpos= yythunkpos982; if (!yymatchString(G, "UL")) goto l981; - } - l982:; if (!yy_Spnl(G)) { goto l981; } if (!yymatchChar(G, '>')) goto l981; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseUl", G->buf+G->pos)); - return 1; - l981:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseUl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenUl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenUl")); if (!yymatchChar(G, '<')) goto l984; if (!yy_Spnl(G)) { goto l984; } - { int yypos985= G->pos, yythunkpos985= G->thunkpos; if (!yymatchString(G, "ul")) goto l986; goto l985; - l986:; G->pos= yypos985; G->thunkpos= yythunkpos985; if (!yymatchString(G, "UL")) goto l984; - } - l985:; if (!yy_Spnl(G)) { goto l984; } - l987:; - { int yypos988= G->pos, yythunkpos988= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l988; } goto l987; - l988:; G->pos= yypos988; G->thunkpos= yythunkpos988; - } if (!yymatchChar(G, '>')) goto l984; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenUl", G->buf+G->pos)); - return 1; - l984:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenUl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockTable(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockTable")); if (!yy_HtmlBlockOpenTable(G)) { goto l989; } - l990:; - { int yypos991= G->pos, yythunkpos991= G->thunkpos; - { int yypos992= G->pos, yythunkpos992= G->thunkpos; if (!yy_HtmlBlockTable(G)) { goto l993; } goto l992; - l993:; G->pos= yypos992; G->thunkpos= yythunkpos992; - { int yypos994= G->pos, yythunkpos994= G->thunkpos; if (!yy_HtmlBlockCloseTable(G)) { goto l994; } goto l991; - l994:; G->pos= yypos994; G->thunkpos= yythunkpos994; - } if (!yymatchDot(G)) goto l991; - } - l992:; goto l990; - l991:; G->pos= yypos991; G->thunkpos= yythunkpos991; - } if (!yy_HtmlBlockCloseTable(G)) { goto l989; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockTable", G->buf+G->pos)); - return 1; - l989:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockTable", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseTable(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseTable")); if (!yymatchChar(G, '<')) goto l995; if (!yy_Spnl(G)) { goto l995; } if (!yymatchChar(G, '/')) goto l995; - { int yypos996= G->pos, yythunkpos996= G->thunkpos; if (!yymatchString(G, "table")) goto l997; goto l996; - l997:; G->pos= yypos996; G->thunkpos= yythunkpos996; if (!yymatchString(G, "TABLE")) goto l995; - } - l996:; if (!yy_Spnl(G)) { goto l995; } if (!yymatchChar(G, '>')) goto l995; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseTable", G->buf+G->pos)); - return 1; - l995:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseTable", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenTable(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenTable")); if (!yymatchChar(G, '<')) goto l998; if (!yy_Spnl(G)) { goto l998; } - { int yypos999= G->pos, yythunkpos999= G->thunkpos; if (!yymatchString(G, "table")) goto l1000; goto l999; - l1000:; G->pos= yypos999; G->thunkpos= yythunkpos999; if (!yymatchString(G, "TABLE")) goto l998; - } - l999:; if (!yy_Spnl(G)) { goto l998; } - l1001:; - { int yypos1002= G->pos, yythunkpos1002= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1002; } goto l1001; - l1002:; G->pos= yypos1002; G->thunkpos= yythunkpos1002; - } if (!yymatchChar(G, '>')) goto l998; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenTable", G->buf+G->pos)); - return 1; - l998:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenTable", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockPre(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockPre")); if (!yy_HtmlBlockOpenPre(G)) { goto l1003; } - l1004:; - { int yypos1005= G->pos, yythunkpos1005= G->thunkpos; - { int yypos1006= G->pos, yythunkpos1006= G->thunkpos; if (!yy_HtmlBlockPre(G)) { goto l1007; } goto l1006; - l1007:; G->pos= yypos1006; G->thunkpos= yythunkpos1006; - { int yypos1008= G->pos, yythunkpos1008= G->thunkpos; if (!yy_HtmlBlockClosePre(G)) { goto l1008; } goto l1005; - l1008:; G->pos= yypos1008; G->thunkpos= yythunkpos1008; - } if (!yymatchDot(G)) goto l1005; - } - l1006:; goto l1004; - l1005:; G->pos= yypos1005; G->thunkpos= yythunkpos1005; - } if (!yy_HtmlBlockClosePre(G)) { goto l1003; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockPre", G->buf+G->pos)); - return 1; - l1003:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockPre", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockClosePre(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockClosePre")); if (!yymatchChar(G, '<')) goto l1009; if (!yy_Spnl(G)) { goto l1009; } if (!yymatchChar(G, '/')) goto l1009; - { int yypos1010= G->pos, yythunkpos1010= G->thunkpos; if (!yymatchString(G, "pre")) goto l1011; goto l1010; - l1011:; G->pos= yypos1010; G->thunkpos= yythunkpos1010; if (!yymatchString(G, "PRE")) goto l1009; - } - l1010:; if (!yy_Spnl(G)) { goto l1009; } if (!yymatchChar(G, '>')) goto l1009; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockClosePre", G->buf+G->pos)); - return 1; - l1009:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockClosePre", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenPre(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenPre")); if (!yymatchChar(G, '<')) goto l1012; if (!yy_Spnl(G)) { goto l1012; } - { int yypos1013= G->pos, yythunkpos1013= G->thunkpos; if (!yymatchString(G, "pre")) goto l1014; goto l1013; - l1014:; G->pos= yypos1013; G->thunkpos= yythunkpos1013; if (!yymatchString(G, "PRE")) goto l1012; - } - l1013:; if (!yy_Spnl(G)) { goto l1012; } - l1015:; - { int yypos1016= G->pos, yythunkpos1016= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1016; } goto l1015; - l1016:; G->pos= yypos1016; G->thunkpos= yythunkpos1016; - } if (!yymatchChar(G, '>')) goto l1012; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenPre", G->buf+G->pos)); - return 1; - l1012:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenPre", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockP(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockP")); if (!yy_HtmlBlockOpenP(G)) { goto l1017; } - l1018:; - { int yypos1019= G->pos, yythunkpos1019= G->thunkpos; - { int yypos1020= G->pos, yythunkpos1020= G->thunkpos; if (!yy_HtmlBlockP(G)) { goto l1021; } goto l1020; - l1021:; G->pos= yypos1020; G->thunkpos= yythunkpos1020; - { int yypos1022= G->pos, yythunkpos1022= G->thunkpos; if (!yy_HtmlBlockCloseP(G)) { goto l1022; } goto l1019; - l1022:; G->pos= yypos1022; G->thunkpos= yythunkpos1022; - } if (!yymatchDot(G)) goto l1019; - } - l1020:; goto l1018; - l1019:; G->pos= yypos1019; G->thunkpos= yythunkpos1019; - } if (!yy_HtmlBlockCloseP(G)) { goto l1017; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockP", G->buf+G->pos)); - return 1; - l1017:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockP", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseP(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseP")); if (!yymatchChar(G, '<')) goto l1023; if (!yy_Spnl(G)) { goto l1023; } if (!yymatchChar(G, '/')) goto l1023; - { int yypos1024= G->pos, yythunkpos1024= G->thunkpos; if (!yymatchChar(G, 'p')) goto l1025; goto l1024; - l1025:; G->pos= yypos1024; G->thunkpos= yythunkpos1024; if (!yymatchChar(G, 'P')) goto l1023; - } - l1024:; if (!yy_Spnl(G)) { goto l1023; } if (!yymatchChar(G, '>')) goto l1023; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseP", G->buf+G->pos)); - return 1; - l1023:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseP", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenP(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenP")); if (!yymatchChar(G, '<')) goto l1026; if (!yy_Spnl(G)) { goto l1026; } - { int yypos1027= G->pos, yythunkpos1027= G->thunkpos; if (!yymatchChar(G, 'p')) goto l1028; goto l1027; - l1028:; G->pos= yypos1027; G->thunkpos= yythunkpos1027; if (!yymatchChar(G, 'P')) goto l1026; - } - l1027:; if (!yy_Spnl(G)) { goto l1026; } - l1029:; - { int yypos1030= G->pos, yythunkpos1030= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1030; } goto l1029; - l1030:; G->pos= yypos1030; G->thunkpos= yythunkpos1030; - } if (!yymatchChar(G, '>')) goto l1026; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenP", G->buf+G->pos)); - return 1; - l1026:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenP", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOl")); if (!yy_HtmlBlockOpenOl(G)) { goto l1031; } - l1032:; - { int yypos1033= G->pos, yythunkpos1033= G->thunkpos; - { int yypos1034= G->pos, yythunkpos1034= G->thunkpos; if (!yy_HtmlBlockOl(G)) { goto l1035; } goto l1034; - l1035:; G->pos= yypos1034; G->thunkpos= yythunkpos1034; - { int yypos1036= G->pos, yythunkpos1036= G->thunkpos; if (!yy_HtmlBlockCloseOl(G)) { goto l1036; } goto l1033; - l1036:; G->pos= yypos1036; G->thunkpos= yythunkpos1036; - } if (!yymatchDot(G)) goto l1033; - } - l1034:; goto l1032; - l1033:; G->pos= yypos1033; G->thunkpos= yythunkpos1033; - } if (!yy_HtmlBlockCloseOl(G)) { goto l1031; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOl", G->buf+G->pos)); - return 1; - l1031:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseOl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseOl")); if (!yymatchChar(G, '<')) goto l1037; if (!yy_Spnl(G)) { goto l1037; } if (!yymatchChar(G, '/')) goto l1037; - { int yypos1038= G->pos, yythunkpos1038= G->thunkpos; if (!yymatchString(G, "ol")) goto l1039; goto l1038; - l1039:; G->pos= yypos1038; G->thunkpos= yythunkpos1038; if (!yymatchString(G, "OL")) goto l1037; - } - l1038:; if (!yy_Spnl(G)) { goto l1037; } if (!yymatchChar(G, '>')) goto l1037; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseOl", G->buf+G->pos)); - return 1; - l1037:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseOl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenOl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenOl")); if (!yymatchChar(G, '<')) goto l1040; if (!yy_Spnl(G)) { goto l1040; } - { int yypos1041= G->pos, yythunkpos1041= G->thunkpos; if (!yymatchString(G, "ol")) goto l1042; goto l1041; - l1042:; G->pos= yypos1041; G->thunkpos= yythunkpos1041; if (!yymatchString(G, "OL")) goto l1040; - } - l1041:; if (!yy_Spnl(G)) { goto l1040; } - l1043:; - { int yypos1044= G->pos, yythunkpos1044= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1044; } goto l1043; - l1044:; G->pos= yypos1044; G->thunkpos= yythunkpos1044; - } if (!yymatchChar(G, '>')) goto l1040; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenOl", G->buf+G->pos)); - return 1; - l1040:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenOl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockNoscript(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockNoscript")); if (!yy_HtmlBlockOpenNoscript(G)) { goto l1045; } - l1046:; - { int yypos1047= G->pos, yythunkpos1047= G->thunkpos; - { int yypos1048= G->pos, yythunkpos1048= G->thunkpos; if (!yy_HtmlBlockNoscript(G)) { goto l1049; } goto l1048; - l1049:; G->pos= yypos1048; G->thunkpos= yythunkpos1048; - { int yypos1050= G->pos, yythunkpos1050= G->thunkpos; if (!yy_HtmlBlockCloseNoscript(G)) { goto l1050; } goto l1047; - l1050:; G->pos= yypos1050; G->thunkpos= yythunkpos1050; - } if (!yymatchDot(G)) goto l1047; - } - l1048:; goto l1046; - l1047:; G->pos= yypos1047; G->thunkpos= yythunkpos1047; - } if (!yy_HtmlBlockCloseNoscript(G)) { goto l1045; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockNoscript", G->buf+G->pos)); - return 1; - l1045:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockNoscript", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseNoscript(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseNoscript")); if (!yymatchChar(G, '<')) goto l1051; if (!yy_Spnl(G)) { goto l1051; } if (!yymatchChar(G, '/')) goto l1051; - { int yypos1052= G->pos, yythunkpos1052= G->thunkpos; if (!yymatchString(G, "noscript")) goto l1053; goto l1052; - l1053:; G->pos= yypos1052; G->thunkpos= yythunkpos1052; if (!yymatchString(G, "NOSCRIPT")) goto l1051; - } - l1052:; if (!yy_Spnl(G)) { goto l1051; } if (!yymatchChar(G, '>')) goto l1051; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseNoscript", G->buf+G->pos)); - return 1; - l1051:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseNoscript", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenNoscript(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenNoscript")); if (!yymatchChar(G, '<')) goto l1054; if (!yy_Spnl(G)) { goto l1054; } - { int yypos1055= G->pos, yythunkpos1055= G->thunkpos; if (!yymatchString(G, "noscript")) goto l1056; goto l1055; - l1056:; G->pos= yypos1055; G->thunkpos= yythunkpos1055; if (!yymatchString(G, "NOSCRIPT")) goto l1054; - } - l1055:; if (!yy_Spnl(G)) { goto l1054; } - l1057:; - { int yypos1058= G->pos, yythunkpos1058= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1058; } goto l1057; - l1058:; G->pos= yypos1058; G->thunkpos= yythunkpos1058; - } if (!yymatchChar(G, '>')) goto l1054; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenNoscript", G->buf+G->pos)); - return 1; - l1054:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenNoscript", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockNoframes(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockNoframes")); if (!yy_HtmlBlockOpenNoframes(G)) { goto l1059; } - l1060:; - { int yypos1061= G->pos, yythunkpos1061= G->thunkpos; - { int yypos1062= G->pos, yythunkpos1062= G->thunkpos; if (!yy_HtmlBlockNoframes(G)) { goto l1063; } goto l1062; - l1063:; G->pos= yypos1062; G->thunkpos= yythunkpos1062; - { int yypos1064= G->pos, yythunkpos1064= G->thunkpos; if (!yy_HtmlBlockCloseNoframes(G)) { goto l1064; } goto l1061; - l1064:; G->pos= yypos1064; G->thunkpos= yythunkpos1064; - } if (!yymatchDot(G)) goto l1061; - } - l1062:; goto l1060; - l1061:; G->pos= yypos1061; G->thunkpos= yythunkpos1061; - } if (!yy_HtmlBlockCloseNoframes(G)) { goto l1059; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockNoframes", G->buf+G->pos)); - return 1; - l1059:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockNoframes", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseNoframes(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseNoframes")); if (!yymatchChar(G, '<')) goto l1065; if (!yy_Spnl(G)) { goto l1065; } if (!yymatchChar(G, '/')) goto l1065; - { int yypos1066= G->pos, yythunkpos1066= G->thunkpos; if (!yymatchString(G, "noframes")) goto l1067; goto l1066; - l1067:; G->pos= yypos1066; G->thunkpos= yythunkpos1066; if (!yymatchString(G, "NOFRAMES")) goto l1065; - } - l1066:; if (!yy_Spnl(G)) { goto l1065; } if (!yymatchChar(G, '>')) goto l1065; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseNoframes", G->buf+G->pos)); - return 1; - l1065:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseNoframes", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenNoframes(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenNoframes")); if (!yymatchChar(G, '<')) goto l1068; if (!yy_Spnl(G)) { goto l1068; } - { int yypos1069= G->pos, yythunkpos1069= G->thunkpos; if (!yymatchString(G, "noframes")) goto l1070; goto l1069; - l1070:; G->pos= yypos1069; G->thunkpos= yythunkpos1069; if (!yymatchString(G, "NOFRAMES")) goto l1068; - } - l1069:; if (!yy_Spnl(G)) { goto l1068; } - l1071:; - { int yypos1072= G->pos, yythunkpos1072= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1072; } goto l1071; - l1072:; G->pos= yypos1072; G->thunkpos= yythunkpos1072; - } if (!yymatchChar(G, '>')) goto l1068; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenNoframes", G->buf+G->pos)); - return 1; - l1068:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenNoframes", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockMenu(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockMenu")); if (!yy_HtmlBlockOpenMenu(G)) { goto l1073; } - l1074:; - { int yypos1075= G->pos, yythunkpos1075= G->thunkpos; - { int yypos1076= G->pos, yythunkpos1076= G->thunkpos; if (!yy_HtmlBlockMenu(G)) { goto l1077; } goto l1076; - l1077:; G->pos= yypos1076; G->thunkpos= yythunkpos1076; - { int yypos1078= G->pos, yythunkpos1078= G->thunkpos; if (!yy_HtmlBlockCloseMenu(G)) { goto l1078; } goto l1075; - l1078:; G->pos= yypos1078; G->thunkpos= yythunkpos1078; - } if (!yymatchDot(G)) goto l1075; - } - l1076:; goto l1074; - l1075:; G->pos= yypos1075; G->thunkpos= yythunkpos1075; - } if (!yy_HtmlBlockCloseMenu(G)) { goto l1073; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockMenu", G->buf+G->pos)); - return 1; - l1073:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockMenu", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseMenu(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseMenu")); if (!yymatchChar(G, '<')) goto l1079; if (!yy_Spnl(G)) { goto l1079; } if (!yymatchChar(G, '/')) goto l1079; - { int yypos1080= G->pos, yythunkpos1080= G->thunkpos; if (!yymatchString(G, "menu")) goto l1081; goto l1080; - l1081:; G->pos= yypos1080; G->thunkpos= yythunkpos1080; if (!yymatchString(G, "MENU")) goto l1079; - } - l1080:; if (!yy_Spnl(G)) { goto l1079; } if (!yymatchChar(G, '>')) goto l1079; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseMenu", G->buf+G->pos)); - return 1; - l1079:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseMenu", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenMenu(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenMenu")); if (!yymatchChar(G, '<')) goto l1082; if (!yy_Spnl(G)) { goto l1082; } - { int yypos1083= G->pos, yythunkpos1083= G->thunkpos; if (!yymatchString(G, "menu")) goto l1084; goto l1083; - l1084:; G->pos= yypos1083; G->thunkpos= yythunkpos1083; if (!yymatchString(G, "MENU")) goto l1082; - } - l1083:; if (!yy_Spnl(G)) { goto l1082; } - l1085:; - { int yypos1086= G->pos, yythunkpos1086= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1086; } goto l1085; - l1086:; G->pos= yypos1086; G->thunkpos= yythunkpos1086; - } if (!yymatchChar(G, '>')) goto l1082; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenMenu", G->buf+G->pos)); - return 1; - l1082:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenMenu", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockH6(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "HtmlBlockH6")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1087; if (!yy_LocMarker(G)) { goto l1087; } yyDo(G, yySet, -1, 0); if (!yy_HtmlBlockOpenH6(G)) { goto l1087; } - l1088:; - { int yypos1089= G->pos, yythunkpos1089= G->thunkpos; - { int yypos1090= G->pos, yythunkpos1090= G->thunkpos; if (!yy_HtmlBlockH6(G)) { goto l1091; } goto l1090; - l1091:; G->pos= yypos1090; G->thunkpos= yythunkpos1090; - { int yypos1092= G->pos, yythunkpos1092= G->thunkpos; if (!yy_HtmlBlockCloseH6(G)) { goto l1092; } goto l1089; - l1092:; G->pos= yypos1092; G->thunkpos= yythunkpos1092; - } if (!yymatchDot(G)) goto l1089; - } - l1090:; goto l1088; - l1089:; G->pos= yypos1089; G->thunkpos= yythunkpos1089; - } if (!yy_HtmlBlockCloseH6(G)) { goto l1087; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1087; yyDo(G, yy_1_HtmlBlockH6, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockH6", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1087:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockH6", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseH6(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseH6")); if (!yymatchChar(G, '<')) goto l1093; if (!yy_Spnl(G)) { goto l1093; } if (!yymatchChar(G, '/')) goto l1093; - { int yypos1094= G->pos, yythunkpos1094= G->thunkpos; if (!yymatchString(G, "h6")) goto l1095; goto l1094; - l1095:; G->pos= yypos1094; G->thunkpos= yythunkpos1094; if (!yymatchString(G, "H6")) goto l1093; - } - l1094:; if (!yy_Spnl(G)) { goto l1093; } if (!yymatchChar(G, '>')) goto l1093; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseH6", G->buf+G->pos)); - return 1; - l1093:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseH6", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenH6(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenH6")); if (!yymatchChar(G, '<')) goto l1096; if (!yy_Spnl(G)) { goto l1096; } - { int yypos1097= G->pos, yythunkpos1097= G->thunkpos; if (!yymatchString(G, "h6")) goto l1098; goto l1097; - l1098:; G->pos= yypos1097; G->thunkpos= yythunkpos1097; if (!yymatchString(G, "H6")) goto l1096; - } - l1097:; if (!yy_Spnl(G)) { goto l1096; } - l1099:; - { int yypos1100= G->pos, yythunkpos1100= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1100; } goto l1099; - l1100:; G->pos= yypos1100; G->thunkpos= yythunkpos1100; - } if (!yymatchChar(G, '>')) goto l1096; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenH6", G->buf+G->pos)); - return 1; - l1096:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenH6", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockH5(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "HtmlBlockH5")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1101; if (!yy_LocMarker(G)) { goto l1101; } yyDo(G, yySet, -1, 0); if (!yy_HtmlBlockOpenH5(G)) { goto l1101; } - l1102:; - { int yypos1103= G->pos, yythunkpos1103= G->thunkpos; - { int yypos1104= G->pos, yythunkpos1104= G->thunkpos; if (!yy_HtmlBlockH5(G)) { goto l1105; } goto l1104; - l1105:; G->pos= yypos1104; G->thunkpos= yythunkpos1104; - { int yypos1106= G->pos, yythunkpos1106= G->thunkpos; if (!yy_HtmlBlockCloseH5(G)) { goto l1106; } goto l1103; - l1106:; G->pos= yypos1106; G->thunkpos= yythunkpos1106; - } if (!yymatchDot(G)) goto l1103; - } - l1104:; goto l1102; - l1103:; G->pos= yypos1103; G->thunkpos= yythunkpos1103; - } if (!yy_HtmlBlockCloseH5(G)) { goto l1101; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1101; yyDo(G, yy_1_HtmlBlockH5, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockH5", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1101:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockH5", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseH5(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseH5")); if (!yymatchChar(G, '<')) goto l1107; if (!yy_Spnl(G)) { goto l1107; } if (!yymatchChar(G, '/')) goto l1107; - { int yypos1108= G->pos, yythunkpos1108= G->thunkpos; if (!yymatchString(G, "h5")) goto l1109; goto l1108; - l1109:; G->pos= yypos1108; G->thunkpos= yythunkpos1108; if (!yymatchString(G, "H5")) goto l1107; - } - l1108:; if (!yy_Spnl(G)) { goto l1107; } if (!yymatchChar(G, '>')) goto l1107; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseH5", G->buf+G->pos)); - return 1; - l1107:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseH5", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenH5(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenH5")); if (!yymatchChar(G, '<')) goto l1110; if (!yy_Spnl(G)) { goto l1110; } - { int yypos1111= G->pos, yythunkpos1111= G->thunkpos; if (!yymatchString(G, "h5")) goto l1112; goto l1111; - l1112:; G->pos= yypos1111; G->thunkpos= yythunkpos1111; if (!yymatchString(G, "H5")) goto l1110; - } - l1111:; if (!yy_Spnl(G)) { goto l1110; } - l1113:; - { int yypos1114= G->pos, yythunkpos1114= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1114; } goto l1113; - l1114:; G->pos= yypos1114; G->thunkpos= yythunkpos1114; - } if (!yymatchChar(G, '>')) goto l1110; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenH5", G->buf+G->pos)); - return 1; - l1110:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenH5", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockH4(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "HtmlBlockH4")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1115; if (!yy_LocMarker(G)) { goto l1115; } yyDo(G, yySet, -1, 0); if (!yy_HtmlBlockOpenH4(G)) { goto l1115; } - l1116:; - { int yypos1117= G->pos, yythunkpos1117= G->thunkpos; - { int yypos1118= G->pos, yythunkpos1118= G->thunkpos; if (!yy_HtmlBlockH4(G)) { goto l1119; } goto l1118; - l1119:; G->pos= yypos1118; G->thunkpos= yythunkpos1118; - { int yypos1120= G->pos, yythunkpos1120= G->thunkpos; if (!yy_HtmlBlockCloseH4(G)) { goto l1120; } goto l1117; - l1120:; G->pos= yypos1120; G->thunkpos= yythunkpos1120; - } if (!yymatchDot(G)) goto l1117; - } - l1118:; goto l1116; - l1117:; G->pos= yypos1117; G->thunkpos= yythunkpos1117; - } if (!yy_HtmlBlockCloseH4(G)) { goto l1115; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1115; yyDo(G, yy_1_HtmlBlockH4, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockH4", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1115:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockH4", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseH4(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseH4")); if (!yymatchChar(G, '<')) goto l1121; if (!yy_Spnl(G)) { goto l1121; } if (!yymatchChar(G, '/')) goto l1121; - { int yypos1122= G->pos, yythunkpos1122= G->thunkpos; if (!yymatchString(G, "h4")) goto l1123; goto l1122; - l1123:; G->pos= yypos1122; G->thunkpos= yythunkpos1122; if (!yymatchString(G, "H4")) goto l1121; - } - l1122:; if (!yy_Spnl(G)) { goto l1121; } if (!yymatchChar(G, '>')) goto l1121; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseH4", G->buf+G->pos)); - return 1; - l1121:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseH4", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenH4(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenH4")); if (!yymatchChar(G, '<')) goto l1124; if (!yy_Spnl(G)) { goto l1124; } - { int yypos1125= G->pos, yythunkpos1125= G->thunkpos; if (!yymatchString(G, "h4")) goto l1126; goto l1125; - l1126:; G->pos= yypos1125; G->thunkpos= yythunkpos1125; if (!yymatchString(G, "H4")) goto l1124; - } - l1125:; if (!yy_Spnl(G)) { goto l1124; } - l1127:; - { int yypos1128= G->pos, yythunkpos1128= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1128; } goto l1127; - l1128:; G->pos= yypos1128; G->thunkpos= yythunkpos1128; - } if (!yymatchChar(G, '>')) goto l1124; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenH4", G->buf+G->pos)); - return 1; - l1124:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenH4", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockH3(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "HtmlBlockH3")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1129; if (!yy_LocMarker(G)) { goto l1129; } yyDo(G, yySet, -1, 0); if (!yy_HtmlBlockOpenH3(G)) { goto l1129; } - l1130:; - { int yypos1131= G->pos, yythunkpos1131= G->thunkpos; - { int yypos1132= G->pos, yythunkpos1132= G->thunkpos; if (!yy_HtmlBlockH3(G)) { goto l1133; } goto l1132; - l1133:; G->pos= yypos1132; G->thunkpos= yythunkpos1132; - { int yypos1134= G->pos, yythunkpos1134= G->thunkpos; if (!yy_HtmlBlockCloseH3(G)) { goto l1134; } goto l1131; - l1134:; G->pos= yypos1134; G->thunkpos= yythunkpos1134; - } if (!yymatchDot(G)) goto l1131; - } - l1132:; goto l1130; - l1131:; G->pos= yypos1131; G->thunkpos= yythunkpos1131; - } if (!yy_HtmlBlockCloseH3(G)) { goto l1129; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1129; yyDo(G, yy_1_HtmlBlockH3, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockH3", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1129:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockH3", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseH3(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseH3")); if (!yymatchChar(G, '<')) goto l1135; if (!yy_Spnl(G)) { goto l1135; } if (!yymatchChar(G, '/')) goto l1135; - { int yypos1136= G->pos, yythunkpos1136= G->thunkpos; if (!yymatchString(G, "h3")) goto l1137; goto l1136; - l1137:; G->pos= yypos1136; G->thunkpos= yythunkpos1136; if (!yymatchString(G, "H3")) goto l1135; - } - l1136:; if (!yy_Spnl(G)) { goto l1135; } if (!yymatchChar(G, '>')) goto l1135; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseH3", G->buf+G->pos)); - return 1; - l1135:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseH3", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenH3(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenH3")); if (!yymatchChar(G, '<')) goto l1138; if (!yy_Spnl(G)) { goto l1138; } - { int yypos1139= G->pos, yythunkpos1139= G->thunkpos; if (!yymatchString(G, "h3")) goto l1140; goto l1139; - l1140:; G->pos= yypos1139; G->thunkpos= yythunkpos1139; if (!yymatchString(G, "H3")) goto l1138; - } - l1139:; if (!yy_Spnl(G)) { goto l1138; } - l1141:; - { int yypos1142= G->pos, yythunkpos1142= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1142; } goto l1141; - l1142:; G->pos= yypos1142; G->thunkpos= yythunkpos1142; - } if (!yymatchChar(G, '>')) goto l1138; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenH3", G->buf+G->pos)); - return 1; - l1138:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenH3", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockH2(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "HtmlBlockH2")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1143; if (!yy_LocMarker(G)) { goto l1143; } yyDo(G, yySet, -1, 0); if (!yy_HtmlBlockOpenH2(G)) { goto l1143; } - l1144:; - { int yypos1145= G->pos, yythunkpos1145= G->thunkpos; - { int yypos1146= G->pos, yythunkpos1146= G->thunkpos; if (!yy_HtmlBlockH2(G)) { goto l1147; } goto l1146; - l1147:; G->pos= yypos1146; G->thunkpos= yythunkpos1146; - { int yypos1148= G->pos, yythunkpos1148= G->thunkpos; if (!yy_HtmlBlockCloseH2(G)) { goto l1148; } goto l1145; - l1148:; G->pos= yypos1148; G->thunkpos= yythunkpos1148; - } if (!yymatchDot(G)) goto l1145; - } - l1146:; goto l1144; - l1145:; G->pos= yypos1145; G->thunkpos= yythunkpos1145; - } if (!yy_HtmlBlockCloseH2(G)) { goto l1143; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1143; yyDo(G, yy_1_HtmlBlockH2, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockH2", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1143:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockH2", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseH2(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseH2")); if (!yymatchChar(G, '<')) goto l1149; if (!yy_Spnl(G)) { goto l1149; } if (!yymatchChar(G, '/')) goto l1149; - { int yypos1150= G->pos, yythunkpos1150= G->thunkpos; if (!yymatchString(G, "h2")) goto l1151; goto l1150; - l1151:; G->pos= yypos1150; G->thunkpos= yythunkpos1150; if (!yymatchString(G, "H2")) goto l1149; - } - l1150:; if (!yy_Spnl(G)) { goto l1149; } if (!yymatchChar(G, '>')) goto l1149; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseH2", G->buf+G->pos)); - return 1; - l1149:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseH2", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenH2(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenH2")); if (!yymatchChar(G, '<')) goto l1152; if (!yy_Spnl(G)) { goto l1152; } - { int yypos1153= G->pos, yythunkpos1153= G->thunkpos; if (!yymatchString(G, "h2")) goto l1154; goto l1153; - l1154:; G->pos= yypos1153; G->thunkpos= yythunkpos1153; if (!yymatchString(G, "H2")) goto l1152; - } - l1153:; if (!yy_Spnl(G)) { goto l1152; } - l1155:; - { int yypos1156= G->pos, yythunkpos1156= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1156; } goto l1155; - l1156:; G->pos= yypos1156; G->thunkpos= yythunkpos1156; - } if (!yymatchChar(G, '>')) goto l1152; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenH2", G->buf+G->pos)); - return 1; - l1152:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenH2", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockH1(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "HtmlBlockH1")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1157; if (!yy_LocMarker(G)) { goto l1157; } yyDo(G, yySet, -1, 0); if (!yy_HtmlBlockOpenH1(G)) { goto l1157; } - l1158:; - { int yypos1159= G->pos, yythunkpos1159= G->thunkpos; - { int yypos1160= G->pos, yythunkpos1160= G->thunkpos; if (!yy_HtmlBlockH1(G)) { goto l1161; } goto l1160; - l1161:; G->pos= yypos1160; G->thunkpos= yythunkpos1160; - { int yypos1162= G->pos, yythunkpos1162= G->thunkpos; if (!yy_HtmlBlockCloseH1(G)) { goto l1162; } goto l1159; - l1162:; G->pos= yypos1162; G->thunkpos= yythunkpos1162; - } if (!yymatchDot(G)) goto l1159; - } - l1160:; goto l1158; - l1159:; G->pos= yypos1159; G->thunkpos= yythunkpos1159; - } if (!yy_HtmlBlockCloseH1(G)) { goto l1157; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1157; yyDo(G, yy_1_HtmlBlockH1, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockH1", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1157:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockH1", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseH1(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseH1")); if (!yymatchChar(G, '<')) goto l1163; if (!yy_Spnl(G)) { goto l1163; } if (!yymatchChar(G, '/')) goto l1163; - { int yypos1164= G->pos, yythunkpos1164= G->thunkpos; if (!yymatchString(G, "h1")) goto l1165; goto l1164; - l1165:; G->pos= yypos1164; G->thunkpos= yythunkpos1164; if (!yymatchString(G, "H1")) goto l1163; - } - l1164:; if (!yy_Spnl(G)) { goto l1163; } if (!yymatchChar(G, '>')) goto l1163; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseH1", G->buf+G->pos)); - return 1; - l1163:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseH1", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenH1(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenH1")); if (!yymatchChar(G, '<')) goto l1166; if (!yy_Spnl(G)) { goto l1166; } - { int yypos1167= G->pos, yythunkpos1167= G->thunkpos; if (!yymatchString(G, "h1")) goto l1168; goto l1167; - l1168:; G->pos= yypos1167; G->thunkpos= yythunkpos1167; if (!yymatchString(G, "H1")) goto l1166; - } - l1167:; if (!yy_Spnl(G)) { goto l1166; } - l1169:; - { int yypos1170= G->pos, yythunkpos1170= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1170; } goto l1169; - l1170:; G->pos= yypos1170; G->thunkpos= yythunkpos1170; - } if (!yymatchChar(G, '>')) goto l1166; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenH1", G->buf+G->pos)); - return 1; - l1166:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenH1", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockForm(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockForm")); if (!yy_HtmlBlockOpenForm(G)) { goto l1171; } - l1172:; - { int yypos1173= G->pos, yythunkpos1173= G->thunkpos; - { int yypos1174= G->pos, yythunkpos1174= G->thunkpos; if (!yy_HtmlBlockForm(G)) { goto l1175; } goto l1174; - l1175:; G->pos= yypos1174; G->thunkpos= yythunkpos1174; - { int yypos1176= G->pos, yythunkpos1176= G->thunkpos; if (!yy_HtmlBlockCloseForm(G)) { goto l1176; } goto l1173; - l1176:; G->pos= yypos1176; G->thunkpos= yythunkpos1176; - } if (!yymatchDot(G)) goto l1173; - } - l1174:; goto l1172; - l1173:; G->pos= yypos1173; G->thunkpos= yythunkpos1173; - } if (!yy_HtmlBlockCloseForm(G)) { goto l1171; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockForm", G->buf+G->pos)); - return 1; - l1171:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockForm", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseForm(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseForm")); if (!yymatchChar(G, '<')) goto l1177; if (!yy_Spnl(G)) { goto l1177; } if (!yymatchChar(G, '/')) goto l1177; - { int yypos1178= G->pos, yythunkpos1178= G->thunkpos; if (!yymatchString(G, "form")) goto l1179; goto l1178; - l1179:; G->pos= yypos1178; G->thunkpos= yythunkpos1178; if (!yymatchString(G, "FORM")) goto l1177; - } - l1178:; if (!yy_Spnl(G)) { goto l1177; } if (!yymatchChar(G, '>')) goto l1177; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseForm", G->buf+G->pos)); - return 1; - l1177:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseForm", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenForm(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenForm")); if (!yymatchChar(G, '<')) goto l1180; if (!yy_Spnl(G)) { goto l1180; } - { int yypos1181= G->pos, yythunkpos1181= G->thunkpos; if (!yymatchString(G, "form")) goto l1182; goto l1181; - l1182:; G->pos= yypos1181; G->thunkpos= yythunkpos1181; if (!yymatchString(G, "FORM")) goto l1180; - } - l1181:; if (!yy_Spnl(G)) { goto l1180; } - l1183:; - { int yypos1184= G->pos, yythunkpos1184= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1184; } goto l1183; - l1184:; G->pos= yypos1184; G->thunkpos= yythunkpos1184; - } if (!yymatchChar(G, '>')) goto l1180; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenForm", G->buf+G->pos)); - return 1; - l1180:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenForm", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockFieldset(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockFieldset")); if (!yy_HtmlBlockOpenFieldset(G)) { goto l1185; } - l1186:; - { int yypos1187= G->pos, yythunkpos1187= G->thunkpos; - { int yypos1188= G->pos, yythunkpos1188= G->thunkpos; if (!yy_HtmlBlockFieldset(G)) { goto l1189; } goto l1188; - l1189:; G->pos= yypos1188; G->thunkpos= yythunkpos1188; - { int yypos1190= G->pos, yythunkpos1190= G->thunkpos; if (!yy_HtmlBlockCloseFieldset(G)) { goto l1190; } goto l1187; - l1190:; G->pos= yypos1190; G->thunkpos= yythunkpos1190; - } if (!yymatchDot(G)) goto l1187; - } - l1188:; goto l1186; - l1187:; G->pos= yypos1187; G->thunkpos= yythunkpos1187; - } if (!yy_HtmlBlockCloseFieldset(G)) { goto l1185; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockFieldset", G->buf+G->pos)); - return 1; - l1185:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockFieldset", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseFieldset(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseFieldset")); if (!yymatchChar(G, '<')) goto l1191; if (!yy_Spnl(G)) { goto l1191; } if (!yymatchChar(G, '/')) goto l1191; - { int yypos1192= G->pos, yythunkpos1192= G->thunkpos; if (!yymatchString(G, "fieldset")) goto l1193; goto l1192; - l1193:; G->pos= yypos1192; G->thunkpos= yythunkpos1192; if (!yymatchString(G, "FIELDSET")) goto l1191; - } - l1192:; if (!yy_Spnl(G)) { goto l1191; } if (!yymatchChar(G, '>')) goto l1191; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseFieldset", G->buf+G->pos)); - return 1; - l1191:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseFieldset", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenFieldset(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenFieldset")); if (!yymatchChar(G, '<')) goto l1194; if (!yy_Spnl(G)) { goto l1194; } - { int yypos1195= G->pos, yythunkpos1195= G->thunkpos; if (!yymatchString(G, "fieldset")) goto l1196; goto l1195; - l1196:; G->pos= yypos1195; G->thunkpos= yythunkpos1195; if (!yymatchString(G, "FIELDSET")) goto l1194; - } - l1195:; if (!yy_Spnl(G)) { goto l1194; } - l1197:; - { int yypos1198= G->pos, yythunkpos1198= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1198; } goto l1197; - l1198:; G->pos= yypos1198; G->thunkpos= yythunkpos1198; - } if (!yymatchChar(G, '>')) goto l1194; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenFieldset", G->buf+G->pos)); - return 1; - l1194:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenFieldset", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockDl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockDl")); if (!yy_HtmlBlockOpenDl(G)) { goto l1199; } - l1200:; - { int yypos1201= G->pos, yythunkpos1201= G->thunkpos; - { int yypos1202= G->pos, yythunkpos1202= G->thunkpos; if (!yy_HtmlBlockDl(G)) { goto l1203; } goto l1202; - l1203:; G->pos= yypos1202; G->thunkpos= yythunkpos1202; - { int yypos1204= G->pos, yythunkpos1204= G->thunkpos; if (!yy_HtmlBlockCloseDl(G)) { goto l1204; } goto l1201; - l1204:; G->pos= yypos1204; G->thunkpos= yythunkpos1204; - } if (!yymatchDot(G)) goto l1201; - } - l1202:; goto l1200; - l1201:; G->pos= yypos1201; G->thunkpos= yythunkpos1201; - } if (!yy_HtmlBlockCloseDl(G)) { goto l1199; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockDl", G->buf+G->pos)); - return 1; - l1199:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockDl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseDl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseDl")); if (!yymatchChar(G, '<')) goto l1205; if (!yy_Spnl(G)) { goto l1205; } if (!yymatchChar(G, '/')) goto l1205; - { int yypos1206= G->pos, yythunkpos1206= G->thunkpos; if (!yymatchString(G, "dl")) goto l1207; goto l1206; - l1207:; G->pos= yypos1206; G->thunkpos= yythunkpos1206; if (!yymatchString(G, "DL")) goto l1205; - } - l1206:; if (!yy_Spnl(G)) { goto l1205; } if (!yymatchChar(G, '>')) goto l1205; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseDl", G->buf+G->pos)); - return 1; - l1205:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseDl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenDl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenDl")); if (!yymatchChar(G, '<')) goto l1208; if (!yy_Spnl(G)) { goto l1208; } - { int yypos1209= G->pos, yythunkpos1209= G->thunkpos; if (!yymatchString(G, "dl")) goto l1210; goto l1209; - l1210:; G->pos= yypos1209; G->thunkpos= yythunkpos1209; if (!yymatchString(G, "DL")) goto l1208; - } - l1209:; if (!yy_Spnl(G)) { goto l1208; } - l1211:; - { int yypos1212= G->pos, yythunkpos1212= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1212; } goto l1211; - l1212:; G->pos= yypos1212; G->thunkpos= yythunkpos1212; - } if (!yymatchChar(G, '>')) goto l1208; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenDl", G->buf+G->pos)); - return 1; - l1208:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenDl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockDiv(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockDiv")); if (!yy_HtmlBlockOpenDiv(G)) { goto l1213; } - l1214:; - { int yypos1215= G->pos, yythunkpos1215= G->thunkpos; - { int yypos1216= G->pos, yythunkpos1216= G->thunkpos; if (!yy_HtmlBlockDiv(G)) { goto l1217; } goto l1216; - l1217:; G->pos= yypos1216; G->thunkpos= yythunkpos1216; - { int yypos1218= G->pos, yythunkpos1218= G->thunkpos; if (!yy_HtmlBlockCloseDiv(G)) { goto l1218; } goto l1215; - l1218:; G->pos= yypos1218; G->thunkpos= yythunkpos1218; - } if (!yymatchDot(G)) goto l1215; - } - l1216:; goto l1214; - l1215:; G->pos= yypos1215; G->thunkpos= yythunkpos1215; - } if (!yy_HtmlBlockCloseDiv(G)) { goto l1213; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockDiv", G->buf+G->pos)); - return 1; - l1213:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockDiv", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseDiv(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseDiv")); if (!yymatchChar(G, '<')) goto l1219; if (!yy_Spnl(G)) { goto l1219; } if (!yymatchChar(G, '/')) goto l1219; - { int yypos1220= G->pos, yythunkpos1220= G->thunkpos; if (!yymatchString(G, "div")) goto l1221; goto l1220; - l1221:; G->pos= yypos1220; G->thunkpos= yythunkpos1220; if (!yymatchString(G, "DIV")) goto l1219; - } - l1220:; if (!yy_Spnl(G)) { goto l1219; } if (!yymatchChar(G, '>')) goto l1219; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseDiv", G->buf+G->pos)); - return 1; - l1219:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseDiv", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenDiv(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenDiv")); if (!yymatchChar(G, '<')) goto l1222; if (!yy_Spnl(G)) { goto l1222; } - { int yypos1223= G->pos, yythunkpos1223= G->thunkpos; if (!yymatchString(G, "div")) goto l1224; goto l1223; - l1224:; G->pos= yypos1223; G->thunkpos= yythunkpos1223; if (!yymatchString(G, "DIV")) goto l1222; - } - l1223:; if (!yy_Spnl(G)) { goto l1222; } - l1225:; - { int yypos1226= G->pos, yythunkpos1226= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1226; } goto l1225; - l1226:; G->pos= yypos1226; G->thunkpos= yythunkpos1226; - } if (!yymatchChar(G, '>')) goto l1222; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenDiv", G->buf+G->pos)); - return 1; - l1222:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenDiv", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockDir(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockDir")); if (!yy_HtmlBlockOpenDir(G)) { goto l1227; } - l1228:; - { int yypos1229= G->pos, yythunkpos1229= G->thunkpos; - { int yypos1230= G->pos, yythunkpos1230= G->thunkpos; if (!yy_HtmlBlockDir(G)) { goto l1231; } goto l1230; - l1231:; G->pos= yypos1230; G->thunkpos= yythunkpos1230; - { int yypos1232= G->pos, yythunkpos1232= G->thunkpos; if (!yy_HtmlBlockCloseDir(G)) { goto l1232; } goto l1229; - l1232:; G->pos= yypos1232; G->thunkpos= yythunkpos1232; - } if (!yymatchDot(G)) goto l1229; - } - l1230:; goto l1228; - l1229:; G->pos= yypos1229; G->thunkpos= yythunkpos1229; - } if (!yy_HtmlBlockCloseDir(G)) { goto l1227; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockDir", G->buf+G->pos)); - return 1; - l1227:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockDir", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseDir(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseDir")); if (!yymatchChar(G, '<')) goto l1233; if (!yy_Spnl(G)) { goto l1233; } if (!yymatchChar(G, '/')) goto l1233; - { int yypos1234= G->pos, yythunkpos1234= G->thunkpos; if (!yymatchString(G, "dir")) goto l1235; goto l1234; - l1235:; G->pos= yypos1234; G->thunkpos= yythunkpos1234; if (!yymatchString(G, "DIR")) goto l1233; - } - l1234:; if (!yy_Spnl(G)) { goto l1233; } if (!yymatchChar(G, '>')) goto l1233; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseDir", G->buf+G->pos)); - return 1; - l1233:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseDir", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenDir(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenDir")); if (!yymatchChar(G, '<')) goto l1236; if (!yy_Spnl(G)) { goto l1236; } - { int yypos1237= G->pos, yythunkpos1237= G->thunkpos; if (!yymatchString(G, "dir")) goto l1238; goto l1237; - l1238:; G->pos= yypos1237; G->thunkpos= yythunkpos1237; if (!yymatchString(G, "DIR")) goto l1236; - } - l1237:; if (!yy_Spnl(G)) { goto l1236; } - l1239:; - { int yypos1240= G->pos, yythunkpos1240= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1240; } goto l1239; - l1240:; G->pos= yypos1240; G->thunkpos= yythunkpos1240; - } if (!yymatchChar(G, '>')) goto l1236; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenDir", G->buf+G->pos)); - return 1; - l1236:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenDir", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCenter(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCenter")); if (!yy_HtmlBlockOpenCenter(G)) { goto l1241; } - l1242:; - { int yypos1243= G->pos, yythunkpos1243= G->thunkpos; - { int yypos1244= G->pos, yythunkpos1244= G->thunkpos; if (!yy_HtmlBlockCenter(G)) { goto l1245; } goto l1244; - l1245:; G->pos= yypos1244; G->thunkpos= yythunkpos1244; - { int yypos1246= G->pos, yythunkpos1246= G->thunkpos; if (!yy_HtmlBlockCloseCenter(G)) { goto l1246; } goto l1243; - l1246:; G->pos= yypos1246; G->thunkpos= yythunkpos1246; - } if (!yymatchDot(G)) goto l1243; - } - l1244:; goto l1242; - l1243:; G->pos= yypos1243; G->thunkpos= yythunkpos1243; - } if (!yy_HtmlBlockCloseCenter(G)) { goto l1241; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCenter", G->buf+G->pos)); - return 1; - l1241:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCenter", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseCenter(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseCenter")); if (!yymatchChar(G, '<')) goto l1247; if (!yy_Spnl(G)) { goto l1247; } if (!yymatchChar(G, '/')) goto l1247; - { int yypos1248= G->pos, yythunkpos1248= G->thunkpos; if (!yymatchString(G, "center")) goto l1249; goto l1248; - l1249:; G->pos= yypos1248; G->thunkpos= yythunkpos1248; if (!yymatchString(G, "CENTER")) goto l1247; - } - l1248:; if (!yy_Spnl(G)) { goto l1247; } if (!yymatchChar(G, '>')) goto l1247; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseCenter", G->buf+G->pos)); - return 1; - l1247:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseCenter", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenCenter(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenCenter")); if (!yymatchChar(G, '<')) goto l1250; if (!yy_Spnl(G)) { goto l1250; } - { int yypos1251= G->pos, yythunkpos1251= G->thunkpos; if (!yymatchString(G, "center")) goto l1252; goto l1251; - l1252:; G->pos= yypos1251; G->thunkpos= yythunkpos1251; if (!yymatchString(G, "CENTER")) goto l1250; - } - l1251:; if (!yy_Spnl(G)) { goto l1250; } - l1253:; - { int yypos1254= G->pos, yythunkpos1254= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1254; } goto l1253; - l1254:; G->pos= yypos1254; G->thunkpos= yythunkpos1254; - } if (!yymatchChar(G, '>')) goto l1250; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenCenter", G->buf+G->pos)); - return 1; - l1250:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenCenter", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockBlockquote(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockBlockquote")); if (!yy_HtmlBlockOpenBlockquote(G)) { goto l1255; } - l1256:; - { int yypos1257= G->pos, yythunkpos1257= G->thunkpos; - { int yypos1258= G->pos, yythunkpos1258= G->thunkpos; if (!yy_HtmlBlockBlockquote(G)) { goto l1259; } goto l1258; - l1259:; G->pos= yypos1258; G->thunkpos= yythunkpos1258; - { int yypos1260= G->pos, yythunkpos1260= G->thunkpos; if (!yy_HtmlBlockCloseBlockquote(G)) { goto l1260; } goto l1257; - l1260:; G->pos= yypos1260; G->thunkpos= yythunkpos1260; - } if (!yymatchDot(G)) goto l1257; - } - l1258:; goto l1256; - l1257:; G->pos= yypos1257; G->thunkpos= yythunkpos1257; - } if (!yy_HtmlBlockCloseBlockquote(G)) { goto l1255; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockBlockquote", G->buf+G->pos)); - return 1; - l1255:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockBlockquote", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseBlockquote(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseBlockquote")); if (!yymatchChar(G, '<')) goto l1261; if (!yy_Spnl(G)) { goto l1261; } if (!yymatchChar(G, '/')) goto l1261; - { int yypos1262= G->pos, yythunkpos1262= G->thunkpos; if (!yymatchString(G, "blockquote")) goto l1263; goto l1262; - l1263:; G->pos= yypos1262; G->thunkpos= yythunkpos1262; if (!yymatchString(G, "BLOCKQUOTE")) goto l1261; - } - l1262:; if (!yy_Spnl(G)) { goto l1261; } if (!yymatchChar(G, '>')) goto l1261; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseBlockquote", G->buf+G->pos)); - return 1; - l1261:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseBlockquote", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenBlockquote(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenBlockquote")); if (!yymatchChar(G, '<')) goto l1264; if (!yy_Spnl(G)) { goto l1264; } - { int yypos1265= G->pos, yythunkpos1265= G->thunkpos; if (!yymatchString(G, "blockquote")) goto l1266; goto l1265; - l1266:; G->pos= yypos1265; G->thunkpos= yythunkpos1265; if (!yymatchString(G, "BLOCKQUOTE")) goto l1264; - } - l1265:; if (!yy_Spnl(G)) { goto l1264; } - l1267:; - { int yypos1268= G->pos, yythunkpos1268= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1268; } goto l1267; - l1268:; G->pos= yypos1268; G->thunkpos= yythunkpos1268; - } if (!yymatchChar(G, '>')) goto l1264; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenBlockquote", G->buf+G->pos)); - return 1; - l1264:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenBlockquote", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockAddress(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockAddress")); if (!yy_HtmlBlockOpenAddress(G)) { goto l1269; } - l1270:; - { int yypos1271= G->pos, yythunkpos1271= G->thunkpos; - { int yypos1272= G->pos, yythunkpos1272= G->thunkpos; if (!yy_HtmlBlockAddress(G)) { goto l1273; } goto l1272; - l1273:; G->pos= yypos1272; G->thunkpos= yythunkpos1272; - { int yypos1274= G->pos, yythunkpos1274= G->thunkpos; if (!yy_HtmlBlockCloseAddress(G)) { goto l1274; } goto l1271; - l1274:; G->pos= yypos1274; G->thunkpos= yythunkpos1274; - } if (!yymatchDot(G)) goto l1271; - } - l1272:; goto l1270; - l1271:; G->pos= yypos1271; G->thunkpos= yythunkpos1271; - } if (!yy_HtmlBlockCloseAddress(G)) { goto l1269; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockAddress", G->buf+G->pos)); - return 1; - l1269:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockAddress", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockCloseAddress(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockCloseAddress")); if (!yymatchChar(G, '<')) goto l1275; if (!yy_Spnl(G)) { goto l1275; } if (!yymatchChar(G, '/')) goto l1275; - { int yypos1276= G->pos, yythunkpos1276= G->thunkpos; if (!yymatchString(G, "address")) goto l1277; goto l1276; - l1277:; G->pos= yypos1276; G->thunkpos= yythunkpos1276; if (!yymatchString(G, "ADDRESS")) goto l1275; - } - l1276:; if (!yy_Spnl(G)) { goto l1275; } if (!yymatchChar(G, '>')) goto l1275; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockCloseAddress", G->buf+G->pos)); - return 1; - l1275:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockCloseAddress", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlAttribute(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlAttribute")); - { int yypos1281= G->pos, yythunkpos1281= G->thunkpos; if (!yy_AlphanumericAscii(G)) { goto l1282; } goto l1281; - l1282:; G->pos= yypos1281; G->thunkpos= yythunkpos1281; if (!yymatchChar(G, '-')) goto l1278; - } - l1281:; - l1279:; - { int yypos1280= G->pos, yythunkpos1280= G->thunkpos; - { int yypos1283= G->pos, yythunkpos1283= G->thunkpos; if (!yy_AlphanumericAscii(G)) { goto l1284; } goto l1283; - l1284:; G->pos= yypos1283; G->thunkpos= yythunkpos1283; if (!yymatchChar(G, '-')) goto l1280; - } - l1283:; goto l1279; - l1280:; G->pos= yypos1280; G->thunkpos= yythunkpos1280; - } if (!yy_Spnl(G)) { goto l1278; } - { int yypos1285= G->pos, yythunkpos1285= G->thunkpos; if (!yymatchChar(G, '=')) goto l1285; if (!yy_Spnl(G)) { goto l1285; } - { int yypos1287= G->pos, yythunkpos1287= G->thunkpos; if (!yy_Quoted(G)) { goto l1288; } goto l1287; - l1288:; G->pos= yypos1287; G->thunkpos= yythunkpos1287; - { int yypos1291= G->pos, yythunkpos1291= G->thunkpos; if (!yymatchChar(G, '>')) goto l1291; goto l1285; - l1291:; G->pos= yypos1291; G->thunkpos= yythunkpos1291; - } if (!yy_Nonspacechar(G)) { goto l1285; } - l1289:; - { int yypos1290= G->pos, yythunkpos1290= G->thunkpos; - { int yypos1292= G->pos, yythunkpos1292= G->thunkpos; if (!yymatchChar(G, '>')) goto l1292; goto l1290; - l1292:; G->pos= yypos1292; G->thunkpos= yythunkpos1292; - } if (!yy_Nonspacechar(G)) { goto l1290; } goto l1289; - l1290:; G->pos= yypos1290; G->thunkpos= yythunkpos1290; - } - } - l1287:; goto l1286; - l1285:; G->pos= yypos1285; G->thunkpos= yythunkpos1285; - } - l1286:; if (!yy_Spnl(G)) { goto l1278; } - yyprintf((stderr, " ok %s @ %s\n", "HtmlAttribute", G->buf+G->pos)); - return 1; - l1278:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlAttribute", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Spnl(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Spnl")); if (!yy_Sp(G)) { goto l1293; } - { int yypos1294= G->pos, yythunkpos1294= G->thunkpos; if (!yy_Newline(G)) { goto l1294; } if (!yy_Sp(G)) { goto l1294; } goto l1295; - l1294:; G->pos= yypos1294; G->thunkpos= yythunkpos1294; - } - l1295:; - yyprintf((stderr, " ok %s @ %s\n", "Spnl", G->buf+G->pos)); - return 1; - l1293:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Spnl", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlockOpenAddress(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HtmlBlockOpenAddress")); if (!yymatchChar(G, '<')) goto l1296; if (!yy_Spnl(G)) { goto l1296; } - { int yypos1297= G->pos, yythunkpos1297= G->thunkpos; if (!yymatchString(G, "address")) goto l1298; goto l1297; - l1298:; G->pos= yypos1297; G->thunkpos= yythunkpos1297; if (!yymatchString(G, "ADDRESS")) goto l1296; - } - l1297:; if (!yy_Spnl(G)) { goto l1296; } - l1299:; - { int yypos1300= G->pos, yythunkpos1300= G->thunkpos; if (!yy_HtmlAttribute(G)) { goto l1300; } goto l1299; - l1300:; G->pos= yypos1300; G->thunkpos= yythunkpos1300; - } if (!yymatchChar(G, '>')) goto l1296; - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlockOpenAddress", G->buf+G->pos)); - return 1; - l1296:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlockOpenAddress", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_OptionallyIndentedLine(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "OptionallyIndentedLine")); - { int yypos1302= G->pos, yythunkpos1302= G->thunkpos; if (!yy_Indent(G)) { goto l1302; } goto l1303; - l1302:; G->pos= yypos1302; G->thunkpos= yythunkpos1302; - } - l1303:; if (!yy_Line(G)) { goto l1301; } - yyprintf((stderr, " ok %s @ %s\n", "OptionallyIndentedLine", G->buf+G->pos)); - return 1; - l1301:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "OptionallyIndentedLine", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Indent(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Indent")); - { int yypos1305= G->pos, yythunkpos1305= G->thunkpos; if (!yymatchChar(G, '\t')) goto l1306; goto l1305; - l1306:; G->pos= yypos1305; G->thunkpos= yythunkpos1305; if (!yymatchString(G, " ")) goto l1304; - } - l1305:; - yyprintf((stderr, " ok %s @ %s\n", "Indent", G->buf+G->pos)); - return 1; - l1304:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Indent", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ListBlockLine(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "ListBlockLine")); - { int yypos1308= G->pos, yythunkpos1308= G->thunkpos; if (!yy_BlankLine(G)) { goto l1308; } goto l1307; - l1308:; G->pos= yypos1308; G->thunkpos= yythunkpos1308; - } - { int yypos1309= G->pos, yythunkpos1309= G->thunkpos; - { int yypos1310= G->pos, yythunkpos1310= G->thunkpos; if (!yy_Indent(G)) { goto l1310; } goto l1311; - l1310:; G->pos= yypos1310; G->thunkpos= yythunkpos1310; - } - l1311:; - { int yypos1312= G->pos, yythunkpos1312= G->thunkpos; if (!yy_Bullet(G)) { goto l1313; } goto l1312; - l1313:; G->pos= yypos1312; G->thunkpos= yythunkpos1312; if (!yy_Enumerator(G)) { goto l1309; } - } - l1312:; goto l1307; - l1309:; G->pos= yypos1309; G->thunkpos= yythunkpos1309; - } - { int yypos1314= G->pos, yythunkpos1314= G->thunkpos; if (!yy_HorizontalRule(G)) { goto l1314; } goto l1307; - l1314:; G->pos= yypos1314; G->thunkpos= yythunkpos1314; - } if (!yy_OptionallyIndentedLine(G)) { goto l1307; } - yyprintf((stderr, " ok %s @ %s\n", "ListBlockLine", G->buf+G->pos)); - return 1; - l1307:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ListBlockLine", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ListContinuationBlock(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "ListContinuationBlock")); if (!yy_StartList(G)) { goto l1315; } yyDo(G, yySet, -1, 0); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1315; - l1316:; - { int yypos1317= G->pos, yythunkpos1317= G->thunkpos; if (!yy_BlankLine(G)) { goto l1317; } goto l1316; - l1317:; G->pos= yypos1317; G->thunkpos= yythunkpos1317; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1315; yyDo(G, yy_1_ListContinuationBlock, G->begin, G->end); if (!yy_Indent(G)) { goto l1315; } if (!yy_ListBlock(G)) { goto l1315; } yyDo(G, yy_2_ListContinuationBlock, G->begin, G->end); - l1318:; - { int yypos1319= G->pos, yythunkpos1319= G->thunkpos; if (!yy_Indent(G)) { goto l1319; } if (!yy_ListBlock(G)) { goto l1319; } yyDo(G, yy_2_ListContinuationBlock, G->begin, G->end); goto l1318; - l1319:; G->pos= yypos1319; G->thunkpos= yythunkpos1319; - } yyDo(G, yy_3_ListContinuationBlock, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "ListContinuationBlock", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1315:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ListContinuationBlock", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ListBlock(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "ListBlock")); if (!yy_StartList(G)) { goto l1320; } yyDo(G, yySet, -1, 0); - { int yypos1321= G->pos, yythunkpos1321= G->thunkpos; if (!yy_BlankLine(G)) { goto l1321; } goto l1320; - l1321:; G->pos= yypos1321; G->thunkpos= yythunkpos1321; - } if (!yy_Line(G)) { goto l1320; } yyDo(G, yy_1_ListBlock, G->begin, G->end); - l1322:; - { int yypos1323= G->pos, yythunkpos1323= G->thunkpos; if (!yy_ListBlockLine(G)) { goto l1323; } yyDo(G, yy_2_ListBlock, G->begin, G->end); goto l1322; - l1323:; G->pos= yypos1323; G->thunkpos= yythunkpos1323; - } yyDo(G, yy_3_ListBlock, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "ListBlock", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1320:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ListBlock", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ListItem(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "ListItem")); - { int yypos1325= G->pos, yythunkpos1325= G->thunkpos; if (!yy_Bullet(G)) { goto l1326; } goto l1325; - l1326:; G->pos= yypos1325; G->thunkpos= yythunkpos1325; if (!yy_Enumerator(G)) { goto l1324; } - } - l1325:; if (!yy_StartList(G)) { goto l1324; } yyDo(G, yySet, -1, 0); if (!yy_ListBlock(G)) { goto l1324; } yyDo(G, yy_1_ListItem, G->begin, G->end); - l1327:; - { int yypos1328= G->pos, yythunkpos1328= G->thunkpos; if (!yy_ListContinuationBlock(G)) { goto l1328; } yyDo(G, yy_2_ListItem, G->begin, G->end); goto l1327; - l1328:; G->pos= yypos1328; G->thunkpos= yythunkpos1328; - } yyDo(G, yy_3_ListItem, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "ListItem", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1324:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ListItem", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Enumerator(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Enumerator")); if (!yy_NonindentSpace(G)) { goto l1329; } yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1329; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l1329; - l1330:; - { int yypos1331= G->pos, yythunkpos1331= G->thunkpos; if (!yymatchClass(G, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l1331; goto l1330; - l1331:; G->pos= yypos1331; G->thunkpos= yythunkpos1331; - } if (!yymatchChar(G, '.')) goto l1329; yyText(G, G->begin, G->end); if (!(YY_END)) goto l1329; if (!yy_Spacechar(G)) { goto l1329; } - l1332:; - { int yypos1333= G->pos, yythunkpos1333= G->thunkpos; if (!yy_Spacechar(G)) { goto l1333; } goto l1332; - l1333:; G->pos= yypos1333; G->thunkpos= yythunkpos1333; - } yyDo(G, yy_1_Enumerator, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Enumerator", G->buf+G->pos)); - return 1; - l1329:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Enumerator", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ListItemTight(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "ListItemTight")); - { int yypos1335= G->pos, yythunkpos1335= G->thunkpos; if (!yy_Bullet(G)) { goto l1336; } goto l1335; - l1336:; G->pos= yypos1335; G->thunkpos= yythunkpos1335; if (!yy_Enumerator(G)) { goto l1334; } - } - l1335:; if (!yy_StartList(G)) { goto l1334; } yyDo(G, yySet, -1, 0); if (!yy_ListBlock(G)) { goto l1334; } yyDo(G, yy_1_ListItemTight, G->begin, G->end); - l1337:; - { int yypos1338= G->pos, yythunkpos1338= G->thunkpos; - { int yypos1339= G->pos, yythunkpos1339= G->thunkpos; if (!yy_BlankLine(G)) { goto l1339; } goto l1338; - l1339:; G->pos= yypos1339; G->thunkpos= yythunkpos1339; - } if (!yy_ListContinuationBlock(G)) { goto l1338; } yyDo(G, yy_2_ListItemTight, G->begin, G->end); goto l1337; - l1338:; G->pos= yypos1338; G->thunkpos= yythunkpos1338; - } - { int yypos1340= G->pos, yythunkpos1340= G->thunkpos; if (!yy_ListContinuationBlock(G)) { goto l1340; } goto l1334; - l1340:; G->pos= yypos1340; G->thunkpos= yythunkpos1340; - } yyDo(G, yy_3_ListItemTight, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "ListItemTight", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1334:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ListItemTight", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ListLoose(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 2, 0); - yyprintf((stderr, "%s\n", "ListLoose")); if (!yy_StartList(G)) { goto l1341; } yyDo(G, yySet, -2, 0); if (!yy_ListItem(G)) { goto l1341; } yyDo(G, yySet, -1, 0); - l1344:; - { int yypos1345= G->pos, yythunkpos1345= G->thunkpos; if (!yy_BlankLine(G)) { goto l1345; } goto l1344; - l1345:; G->pos= yypos1345; G->thunkpos= yythunkpos1345; - } yyDo(G, yy_1_ListLoose, G->begin, G->end); - l1342:; - { int yypos1343= G->pos, yythunkpos1343= G->thunkpos; if (!yy_ListItem(G)) { goto l1343; } yyDo(G, yySet, -1, 0); - l1346:; - { int yypos1347= G->pos, yythunkpos1347= G->thunkpos; if (!yy_BlankLine(G)) { goto l1347; } goto l1346; - l1347:; G->pos= yypos1347; G->thunkpos= yythunkpos1347; - } yyDo(G, yy_1_ListLoose, G->begin, G->end); goto l1342; - l1343:; G->pos= yypos1343; G->thunkpos= yythunkpos1343; - } yyDo(G, yy_2_ListLoose, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "ListLoose", G->buf+G->pos)); yyDo(G, yyPop, 2, 0); - return 1; - l1341:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ListLoose", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_ListTight(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "ListTight")); if (!yy_StartList(G)) { goto l1348; } yyDo(G, yySet, -1, 0); if (!yy_ListItemTight(G)) { goto l1348; } yyDo(G, yy_1_ListTight, G->begin, G->end); - l1349:; - { int yypos1350= G->pos, yythunkpos1350= G->thunkpos; if (!yy_ListItemTight(G)) { goto l1350; } yyDo(G, yy_1_ListTight, G->begin, G->end); goto l1349; - l1350:; G->pos= yypos1350; G->thunkpos= yythunkpos1350; - } - l1351:; - { int yypos1352= G->pos, yythunkpos1352= G->thunkpos; if (!yy_BlankLine(G)) { goto l1352; } goto l1351; - l1352:; G->pos= yypos1352; G->thunkpos= yythunkpos1352; - } - { int yypos1353= G->pos, yythunkpos1353= G->thunkpos; - { int yypos1354= G->pos, yythunkpos1354= G->thunkpos; if (!yy_Bullet(G)) { goto l1355; } goto l1354; - l1355:; G->pos= yypos1354; G->thunkpos= yythunkpos1354; if (!yy_Enumerator(G)) { goto l1353; } - } - l1354:; goto l1348; - l1353:; G->pos= yypos1353; G->thunkpos= yythunkpos1353; - } yyDo(G, yy_2_ListTight, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "ListTight", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1348:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ListTight", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Spacechar(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Spacechar")); - { int yypos1357= G->pos, yythunkpos1357= G->thunkpos; if (!yymatchChar(G, ' ')) goto l1358; goto l1357; - l1358:; G->pos= yypos1357; G->thunkpos= yythunkpos1357; if (!yymatchChar(G, '\t')) goto l1356; - } - l1357:; - yyprintf((stderr, " ok %s @ %s\n", "Spacechar", G->buf+G->pos)); - return 1; - l1356:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Spacechar", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Bullet(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Bullet")); - { int yypos1360= G->pos, yythunkpos1360= G->thunkpos; if (!yy_HorizontalRule(G)) { goto l1360; } goto l1359; - l1360:; G->pos= yypos1360; G->thunkpos= yythunkpos1360; - } if (!yy_NonindentSpace(G)) { goto l1359; } yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1359; - { int yypos1361= G->pos, yythunkpos1361= G->thunkpos; if (!yymatchChar(G, '+')) goto l1362; goto l1361; - l1362:; G->pos= yypos1361; G->thunkpos= yythunkpos1361; if (!yymatchChar(G, '*')) goto l1363; goto l1361; - l1363:; G->pos= yypos1361; G->thunkpos= yythunkpos1361; if (!yymatchChar(G, '-')) goto l1359; - } - l1361:; yyText(G, G->begin, G->end); if (!(YY_END)) goto l1359; if (!yy_Spacechar(G)) { goto l1359; } - l1364:; - { int yypos1365= G->pos, yythunkpos1365= G->thunkpos; if (!yy_Spacechar(G)) { goto l1365; } goto l1364; - l1365:; G->pos= yypos1365; G->thunkpos= yythunkpos1365; - } yyDo(G, yy_1_Bullet, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Bullet", G->buf+G->pos)); - return 1; - l1359:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Bullet", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_VerbatimChunk(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "VerbatimChunk")); - l1367:; - { int yypos1368= G->pos, yythunkpos1368= G->thunkpos; if (!yy_BlankLine(G)) { goto l1368; } goto l1367; - l1368:; G->pos= yypos1368; G->thunkpos= yythunkpos1368; - } if (!yy_NonblankIndentedLine(G)) { goto l1366; } - l1369:; - { int yypos1370= G->pos, yythunkpos1370= G->thunkpos; if (!yy_NonblankIndentedLine(G)) { goto l1370; } goto l1369; - l1370:; G->pos= yypos1370; G->thunkpos= yythunkpos1370; - } - yyprintf((stderr, " ok %s @ %s\n", "VerbatimChunk", G->buf+G->pos)); - return 1; - l1366:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "VerbatimChunk", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_IndentedLine(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "IndentedLine")); if (!yy_Indent(G)) { goto l1371; } if (!yy_Line(G)) { goto l1371; } - yyprintf((stderr, " ok %s @ %s\n", "IndentedLine", G->buf+G->pos)); - return 1; - l1371:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "IndentedLine", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_NonblankIndentedLine(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "NonblankIndentedLine")); - { int yypos1373= G->pos, yythunkpos1373= G->thunkpos; if (!yy_BlankLine(G)) { goto l1373; } goto l1372; - l1373:; G->pos= yypos1373; G->thunkpos= yythunkpos1373; - } if (!yy_IndentedLine(G)) { goto l1372; } - yyprintf((stderr, " ok %s @ %s\n", "NonblankIndentedLine", G->buf+G->pos)); - return 1; - l1372:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NonblankIndentedLine", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Line(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Line")); if (!yy_RawLine(G)) { goto l1374; } yyDo(G, yy_1_Line, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Line", G->buf+G->pos)); - return 1; - l1374:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Line", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_StartList(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "StartList")); - { int yypos1376= G->pos, yythunkpos1376= G->thunkpos; if (!yymatchDot(G)) goto l1375; G->pos= yypos1376; G->thunkpos= yythunkpos1376; - } yyDo(G, yy_1_StartList, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "StartList", G->buf+G->pos)); - return 1; - l1375:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "StartList", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_BlockQuoteRaw(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "BlockQuoteRaw")); if (!yy_StartList(G)) { goto l1377; } yyDo(G, yySet, -1, 0); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1377; if (!yymatchChar(G, '>')) goto l1377; - { int yypos1380= G->pos, yythunkpos1380= G->thunkpos; if (!yymatchChar(G, ' ')) goto l1380; goto l1381; - l1380:; G->pos= yypos1380; G->thunkpos= yythunkpos1380; - } - l1381:; yyText(G, G->begin, G->end); if (!(YY_END)) goto l1377; yyDo(G, yy_1_BlockQuoteRaw, G->begin, G->end); if (!yy_Line(G)) { goto l1377; } yyDo(G, yy_2_BlockQuoteRaw, G->begin, G->end); - l1382:; - { int yypos1383= G->pos, yythunkpos1383= G->thunkpos; - { int yypos1384= G->pos, yythunkpos1384= G->thunkpos; if (!yymatchChar(G, '>')) goto l1384; goto l1383; - l1384:; G->pos= yypos1384; G->thunkpos= yythunkpos1384; - } - { int yypos1385= G->pos, yythunkpos1385= G->thunkpos; if (!yy_BlankLine(G)) { goto l1385; } goto l1383; - l1385:; G->pos= yypos1385; G->thunkpos= yythunkpos1385; - } if (!yy_Line(G)) { goto l1383; } yyDo(G, yy_3_BlockQuoteRaw, G->begin, G->end); goto l1382; - l1383:; G->pos= yypos1383; G->thunkpos= yythunkpos1383; - } - l1386:; - { int yypos1387= G->pos, yythunkpos1387= G->thunkpos; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1387; if (!yy_BlankLine(G)) { goto l1387; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1387; yyDo(G, yy_4_BlockQuoteRaw, G->begin, G->end); goto l1386; - l1387:; G->pos= yypos1387; G->thunkpos= yythunkpos1387; - } - l1378:; - { int yypos1379= G->pos, yythunkpos1379= G->thunkpos; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1379; if (!yymatchChar(G, '>')) goto l1379; - { int yypos1388= G->pos, yythunkpos1388= G->thunkpos; if (!yymatchChar(G, ' ')) goto l1388; goto l1389; - l1388:; G->pos= yypos1388; G->thunkpos= yythunkpos1388; - } - l1389:; yyText(G, G->begin, G->end); if (!(YY_END)) goto l1379; yyDo(G, yy_1_BlockQuoteRaw, G->begin, G->end); if (!yy_Line(G)) { goto l1379; } yyDo(G, yy_2_BlockQuoteRaw, G->begin, G->end); - l1390:; - { int yypos1391= G->pos, yythunkpos1391= G->thunkpos; - { int yypos1392= G->pos, yythunkpos1392= G->thunkpos; if (!yymatchChar(G, '>')) goto l1392; goto l1391; - l1392:; G->pos= yypos1392; G->thunkpos= yythunkpos1392; - } - { int yypos1393= G->pos, yythunkpos1393= G->thunkpos; if (!yy_BlankLine(G)) { goto l1393; } goto l1391; - l1393:; G->pos= yypos1393; G->thunkpos= yythunkpos1393; - } if (!yy_Line(G)) { goto l1391; } yyDo(G, yy_3_BlockQuoteRaw, G->begin, G->end); goto l1390; - l1391:; G->pos= yypos1391; G->thunkpos= yythunkpos1391; - } - l1394:; - { int yypos1395= G->pos, yythunkpos1395= G->thunkpos; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1395; if (!yy_BlankLine(G)) { goto l1395; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1395; yyDo(G, yy_4_BlockQuoteRaw, G->begin, G->end); goto l1394; - l1395:; G->pos= yypos1395; G->thunkpos= yythunkpos1395; - } goto l1378; - l1379:; G->pos= yypos1379; G->thunkpos= yythunkpos1379; - } yyDo(G, yy_5_BlockQuoteRaw, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "BlockQuoteRaw", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1377:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "BlockQuoteRaw", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Endline(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Endline")); - { int yypos1397= G->pos, yythunkpos1397= G->thunkpos; if (!yy_LineBreak(G)) { goto l1398; } goto l1397; - l1398:; G->pos= yypos1397; G->thunkpos= yythunkpos1397; if (!yy_TerminalEndline(G)) { goto l1399; } goto l1397; - l1399:; G->pos= yypos1397; G->thunkpos= yythunkpos1397; if (!yy_NormalEndline(G)) { goto l1396; } - } - l1397:; - yyprintf((stderr, " ok %s @ %s\n", "Endline", G->buf+G->pos)); - return 1; - l1396:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Endline", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_RawLine(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "RawLine")); - { int yypos1401= G->pos, yythunkpos1401= G->thunkpos; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1402; - l1403:; - { int yypos1404= G->pos, yythunkpos1404= G->thunkpos; - { int yypos1405= G->pos, yythunkpos1405= G->thunkpos; if (!yymatchChar(G, '\r')) goto l1405; goto l1404; - l1405:; G->pos= yypos1405; G->thunkpos= yythunkpos1405; - } - { int yypos1406= G->pos, yythunkpos1406= G->thunkpos; if (!yymatchChar(G, '\n')) goto l1406; goto l1404; - l1406:; G->pos= yypos1406; G->thunkpos= yythunkpos1406; - } if (!yymatchDot(G)) goto l1404; goto l1403; - l1404:; G->pos= yypos1404; G->thunkpos= yythunkpos1404; - } if (!yy_Newline(G)) { goto l1402; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1402; goto l1401; - l1402:; G->pos= yypos1401; G->thunkpos= yythunkpos1401; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1400; if (!yymatchDot(G)) goto l1400; - l1407:; - { int yypos1408= G->pos, yythunkpos1408= G->thunkpos; if (!yymatchDot(G)) goto l1408; goto l1407; - l1408:; G->pos= yypos1408; G->thunkpos= yythunkpos1408; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1400; if (!yy_Eof(G)) { goto l1400; } - } - l1401:; yyDo(G, yy_1_RawLine, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "RawLine", G->buf+G->pos)); - return 1; - l1400:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "RawLine", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_SetextBottom2(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "SetextBottom2")); if (!yymatchString(G, "----")) goto l1409; - l1410:; - { int yypos1411= G->pos, yythunkpos1411= G->thunkpos; if (!yymatchChar(G, '-')) goto l1411; goto l1410; - l1411:; G->pos= yypos1411; G->thunkpos= yythunkpos1411; - } if (!yy_Newline(G)) { goto l1409; } - yyprintf((stderr, " ok %s @ %s\n", "SetextBottom2", G->buf+G->pos)); - return 1; - l1409:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SetextBottom2", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_SetextBottom1(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "SetextBottom1")); if (!yymatchString(G, "===")) goto l1412; - l1413:; - { int yypos1414= G->pos, yythunkpos1414= G->thunkpos; if (!yymatchChar(G, '=')) goto l1414; goto l1413; - l1414:; G->pos= yypos1414; G->thunkpos= yythunkpos1414; - } if (!yy_Newline(G)) { goto l1412; } - yyprintf((stderr, " ok %s @ %s\n", "SetextBottom1", G->buf+G->pos)); - return 1; - l1412:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SetextBottom1", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_SetextHeading2(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "SetextHeading2")); - { int yypos1416= G->pos, yythunkpos1416= G->thunkpos; if (!yy_RawLine(G)) { goto l1415; } if (!yy_SetextBottom2(G)) { goto l1415; } G->pos= yypos1416; G->thunkpos= yythunkpos1416; - } if (!yy_LocMarker(G)) { goto l1415; } yyDo(G, yySet, -1, 0); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1415; - { int yypos1419= G->pos, yythunkpos1419= G->thunkpos; if (!yy_Endline(G)) { goto l1419; } goto l1415; - l1419:; G->pos= yypos1419; G->thunkpos= yythunkpos1419; - } if (!yy_Inline(G)) { goto l1415; } - l1417:; - { int yypos1418= G->pos, yythunkpos1418= G->thunkpos; - { int yypos1420= G->pos, yythunkpos1420= G->thunkpos; if (!yy_Endline(G)) { goto l1420; } goto l1418; - l1420:; G->pos= yypos1420; G->thunkpos= yythunkpos1420; - } if (!yy_Inline(G)) { goto l1418; } goto l1417; - l1418:; G->pos= yypos1418; G->thunkpos= yythunkpos1418; - } - { int yypos1421= G->pos, yythunkpos1421= G->thunkpos; if (!yy_Sp(G)) { goto l1421; } goto l1422; - l1421:; G->pos= yypos1421; G->thunkpos= yythunkpos1421; - } - l1422:; if (!yy_Newline(G)) { goto l1415; } if (!yy_SetextBottom2(G)) { goto l1415; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1415; yyDo(G, yy_1_SetextHeading2, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "SetextHeading2", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1415:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SetextHeading2", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_SetextHeading1(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "SetextHeading1")); - { int yypos1424= G->pos, yythunkpos1424= G->thunkpos; if (!yy_RawLine(G)) { goto l1423; } if (!yy_SetextBottom1(G)) { goto l1423; } G->pos= yypos1424; G->thunkpos= yythunkpos1424; - } if (!yy_LocMarker(G)) { goto l1423; } yyDo(G, yySet, -1, 0); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1423; - { int yypos1427= G->pos, yythunkpos1427= G->thunkpos; if (!yy_Endline(G)) { goto l1427; } goto l1423; - l1427:; G->pos= yypos1427; G->thunkpos= yythunkpos1427; - } if (!yy_Inline(G)) { goto l1423; } - l1425:; - { int yypos1426= G->pos, yythunkpos1426= G->thunkpos; - { int yypos1428= G->pos, yythunkpos1428= G->thunkpos; if (!yy_Endline(G)) { goto l1428; } goto l1426; - l1428:; G->pos= yypos1428; G->thunkpos= yythunkpos1428; - } if (!yy_Inline(G)) { goto l1426; } goto l1425; - l1426:; G->pos= yypos1426; G->thunkpos= yythunkpos1426; - } - { int yypos1429= G->pos, yythunkpos1429= G->thunkpos; if (!yy_Sp(G)) { goto l1429; } goto l1430; - l1429:; G->pos= yypos1429; G->thunkpos= yythunkpos1429; - } - l1430:; if (!yy_Newline(G)) { goto l1423; } if (!yy_SetextBottom1(G)) { goto l1423; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1423; yyDo(G, yy_1_SetextHeading1, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "SetextHeading1", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1423:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SetextHeading1", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_SetextHeading(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "SetextHeading")); - { int yypos1432= G->pos, yythunkpos1432= G->thunkpos; if (!yy_SetextHeading1(G)) { goto l1433; } goto l1432; - l1433:; G->pos= yypos1432; G->thunkpos= yythunkpos1432; if (!yy_SetextHeading2(G)) { goto l1431; } - } - l1432:; - yyprintf((stderr, " ok %s @ %s\n", "SetextHeading", G->buf+G->pos)); - return 1; - l1431:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SetextHeading", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_AtxHeading(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "AtxHeading")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1434; if (!yy_AtxStart(G)) { goto l1434; } yyDo(G, yySet, -1, 0); - { int yypos1435= G->pos, yythunkpos1435= G->thunkpos; if (!yy_Sp(G)) { goto l1435; } goto l1436; - l1435:; G->pos= yypos1435; G->thunkpos= yythunkpos1435; - } - l1436:; if (!yy_AtxInline(G)) { goto l1434; } - l1437:; - { int yypos1438= G->pos, yythunkpos1438= G->thunkpos; if (!yy_AtxInline(G)) { goto l1438; } goto l1437; - l1438:; G->pos= yypos1438; G->thunkpos= yythunkpos1438; - } - { int yypos1439= G->pos, yythunkpos1439= G->thunkpos; - { int yypos1441= G->pos, yythunkpos1441= G->thunkpos; if (!yy_Sp(G)) { goto l1441; } goto l1442; - l1441:; G->pos= yypos1441; G->thunkpos= yythunkpos1441; - } - l1442:; - l1443:; - { int yypos1444= G->pos, yythunkpos1444= G->thunkpos; if (!yymatchChar(G, '#')) goto l1444; goto l1443; - l1444:; G->pos= yypos1444; G->thunkpos= yythunkpos1444; - } if (!yy_Sp(G)) { goto l1439; } goto l1440; - l1439:; G->pos= yypos1439; G->thunkpos= yythunkpos1439; - } - l1440:; if (!yy_Newline(G)) { goto l1434; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1434; yyDo(G, yy_1_AtxHeading, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "AtxHeading", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1434:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "AtxHeading", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_AtxStart(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "AtxStart")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1445; - { int yypos1446= G->pos, yythunkpos1446= G->thunkpos; if (!yymatchString(G, "######")) goto l1447; goto l1446; - l1447:; G->pos= yypos1446; G->thunkpos= yythunkpos1446; if (!yymatchString(G, "#####")) goto l1448; goto l1446; - l1448:; G->pos= yypos1446; G->thunkpos= yythunkpos1446; if (!yymatchString(G, "####")) goto l1449; goto l1446; - l1449:; G->pos= yypos1446; G->thunkpos= yythunkpos1446; if (!yymatchString(G, "###")) goto l1450; goto l1446; - l1450:; G->pos= yypos1446; G->thunkpos= yythunkpos1446; if (!yymatchString(G, "##")) goto l1451; goto l1446; - l1451:; G->pos= yypos1446; G->thunkpos= yythunkpos1446; if (!yymatchChar(G, '#')) goto l1445; - } - l1446:; yyText(G, G->begin, G->end); if (!(YY_END)) goto l1445; yyDo(G, yy_1_AtxStart, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "AtxStart", G->buf+G->pos)); - return 1; - l1445:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "AtxStart", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Inline(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Inline")); - { int yypos1453= G->pos, yythunkpos1453= G->thunkpos; if (!yy_Str(G)) { goto l1454; } goto l1453; - l1454:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_Endline(G)) { goto l1455; } goto l1453; - l1455:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_UlOrStarLine(G)) { goto l1456; } goto l1453; - l1456:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_Space(G)) { goto l1457; } goto l1453; - l1457:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_Math(G)) { goto l1458; } goto l1453; - l1458:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_Strong(G)) { goto l1459; } goto l1453; - l1459:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_Emph(G)) { goto l1460; } goto l1453; - l1460:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_Image(G)) { goto l1461; } goto l1453; - l1461:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_Link(G)) { goto l1462; } goto l1453; - l1462:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_NoteReference(G)) { goto l1463; } goto l1453; - l1463:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_InlineNote(G)) { goto l1464; } goto l1453; - l1464:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_Code(G)) { goto l1465; } goto l1453; - l1465:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_RawHtml(G)) { goto l1466; } goto l1453; - l1466:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_Entity(G)) { goto l1467; } goto l1453; - l1467:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_EscapedChar(G)) { goto l1468; } goto l1453; - l1468:; G->pos= yypos1453; G->thunkpos= yythunkpos1453; if (!yy_Symbol(G)) { goto l1452; } - } - l1453:; - yyprintf((stderr, " ok %s @ %s\n", "Inline", G->buf+G->pos)); - return 1; - l1452:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Inline", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Sp(GREG *G) -{ - yyprintf((stderr, "%s\n", "Sp")); - l1470:; - { int yypos1471= G->pos, yythunkpos1471= G->thunkpos; if (!yy_Spacechar(G)) { goto l1471; } goto l1470; - l1471:; G->pos= yypos1471; G->thunkpos= yythunkpos1471; - } - yyprintf((stderr, " ok %s @ %s\n", "Sp", G->buf+G->pos)); - return 1; -} -YY_RULE(int) yy_Newline(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Newline")); - { int yypos1473= G->pos, yythunkpos1473= G->thunkpos; if (!yymatchChar(G, '\n')) goto l1474; goto l1473; - l1474:; G->pos= yypos1473; G->thunkpos= yythunkpos1473; if (!yymatchChar(G, '\r')) goto l1472; - { int yypos1475= G->pos, yythunkpos1475= G->thunkpos; if (!yymatchChar(G, '\n')) goto l1475; goto l1476; - l1475:; G->pos= yypos1475; G->thunkpos= yythunkpos1475; - } - l1476:; - } - l1473:; - yyprintf((stderr, " ok %s @ %s\n", "Newline", G->buf+G->pos)); - return 1; - l1472:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Newline", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_AtxInline(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "AtxInline")); - { int yypos1478= G->pos, yythunkpos1478= G->thunkpos; if (!yy_Newline(G)) { goto l1478; } goto l1477; - l1478:; G->pos= yypos1478; G->thunkpos= yythunkpos1478; - } - { int yypos1479= G->pos, yythunkpos1479= G->thunkpos; - { int yypos1480= G->pos, yythunkpos1480= G->thunkpos; if (!yy_Sp(G)) { goto l1480; } goto l1481; - l1480:; G->pos= yypos1480; G->thunkpos= yythunkpos1480; - } - l1481:; - l1482:; - { int yypos1483= G->pos, yythunkpos1483= G->thunkpos; if (!yymatchChar(G, '#')) goto l1483; goto l1482; - l1483:; G->pos= yypos1483; G->thunkpos= yythunkpos1483; - } if (!yy_Sp(G)) { goto l1479; } if (!yy_Newline(G)) { goto l1479; } goto l1477; - l1479:; G->pos= yypos1479; G->thunkpos= yythunkpos1479; - } if (!yy_Inline(G)) { goto l1477; } - yyprintf((stderr, " ok %s @ %s\n", "AtxInline", G->buf+G->pos)); - return 1; - l1477:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "AtxInline", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Inlines(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Inlines")); - { int yypos1487= G->pos, yythunkpos1487= G->thunkpos; - { int yypos1489= G->pos, yythunkpos1489= G->thunkpos; if (!yy_Endline(G)) { goto l1489; } goto l1488; - l1489:; G->pos= yypos1489; G->thunkpos= yythunkpos1489; - } if (!yy_Inline(G)) { goto l1488; } goto l1487; - l1488:; G->pos= yypos1487; G->thunkpos= yythunkpos1487; if (!yy_Endline(G)) { goto l1484; } - { int yypos1490= G->pos, yythunkpos1490= G->thunkpos; if (!yy_Inline(G)) { goto l1484; } G->pos= yypos1490; G->thunkpos= yythunkpos1490; - } - } - l1487:; - l1485:; - { int yypos1486= G->pos, yythunkpos1486= G->thunkpos; - { int yypos1491= G->pos, yythunkpos1491= G->thunkpos; - { int yypos1493= G->pos, yythunkpos1493= G->thunkpos; if (!yy_Endline(G)) { goto l1493; } goto l1492; - l1493:; G->pos= yypos1493; G->thunkpos= yythunkpos1493; - } if (!yy_Inline(G)) { goto l1492; } goto l1491; - l1492:; G->pos= yypos1491; G->thunkpos= yythunkpos1491; if (!yy_Endline(G)) { goto l1486; } - { int yypos1494= G->pos, yythunkpos1494= G->thunkpos; if (!yy_Inline(G)) { goto l1486; } G->pos= yypos1494; G->thunkpos= yythunkpos1494; - } - } - l1491:; goto l1485; - l1486:; G->pos= yypos1486; G->thunkpos= yythunkpos1486; - } - { int yypos1495= G->pos, yythunkpos1495= G->thunkpos; if (!yy_Endline(G)) { goto l1495; } goto l1496; - l1495:; G->pos= yypos1495; G->thunkpos= yythunkpos1495; - } - l1496:; - yyprintf((stderr, " ok %s @ %s\n", "Inlines", G->buf+G->pos)); - return 1; - l1484:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Inlines", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_NonindentSpace(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "NonindentSpace")); - { int yypos1498= G->pos, yythunkpos1498= G->thunkpos; if (!yymatchString(G, " ")) goto l1499; goto l1498; - l1499:; G->pos= yypos1498; G->thunkpos= yythunkpos1498; if (!yymatchString(G, " ")) goto l1500; goto l1498; - l1500:; G->pos= yypos1498; G->thunkpos= yythunkpos1498; if (!yymatchChar(G, ' ')) goto l1501; goto l1498; - l1501:; G->pos= yypos1498; G->thunkpos= yythunkpos1498; if (!yymatchString(G, "")) goto l1497; - } - l1498:; - yyprintf((stderr, " ok %s @ %s\n", "NonindentSpace", G->buf+G->pos)); - return 1; - l1497:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NonindentSpace", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Plain(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Plain")); if (!yy_Inlines(G)) { goto l1502; } - yyprintf((stderr, " ok %s @ %s\n", "Plain", G->buf+G->pos)); - return 1; - l1502:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Plain", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Para(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Para")); if (!yy_NonindentSpace(G)) { goto l1503; } if (!yy_Inlines(G)) { goto l1503; } if (!yy_BlankLine(G)) { goto l1503; } - l1504:; - { int yypos1505= G->pos, yythunkpos1505= G->thunkpos; if (!yy_BlankLine(G)) { goto l1505; } goto l1504; - l1505:; G->pos= yypos1505; G->thunkpos= yythunkpos1505; - } - yyprintf((stderr, " ok %s @ %s\n", "Para", G->buf+G->pos)); - return 1; - l1503:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Para", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_StyleBlock(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "StyleBlock")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1506; if (!yy_LocMarker(G)) { goto l1506; } yyDo(G, yySet, -1, 0); if (!yy_InStyleTags(G)) { goto l1506; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1506; - l1507:; - { int yypos1508= G->pos, yythunkpos1508= G->thunkpos; if (!yy_BlankLine(G)) { goto l1508; } goto l1507; - l1508:; G->pos= yypos1508; G->thunkpos= yythunkpos1508; - } yyDo(G, yy_1_StyleBlock, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "StyleBlock", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1506:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "StyleBlock", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HtmlBlock(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "HtmlBlock")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1509; if (!yy_LocMarker(G)) { goto l1509; } yyDo(G, yySet, -1, 0); - { int yypos1510= G->pos, yythunkpos1510= G->thunkpos; if (!yy_HtmlBlockInTags(G)) { goto l1511; } goto l1510; - l1511:; G->pos= yypos1510; G->thunkpos= yythunkpos1510; if (!yy_HtmlComment(G)) { goto l1512; } goto l1510; - l1512:; G->pos= yypos1510; G->thunkpos= yythunkpos1510; if (!yy_HtmlBlockSelfClosing(G)) { goto l1509; } - } - l1510:; yyText(G, G->begin, G->end); if (!(YY_END)) goto l1509; if (!yy_BlankLine(G)) { goto l1509; } - l1513:; - { int yypos1514= G->pos, yythunkpos1514= G->thunkpos; if (!yy_BlankLine(G)) { goto l1514; } goto l1513; - l1514:; G->pos= yypos1514; G->thunkpos= yythunkpos1514; - } yyDo(G, yy_1_HtmlBlock, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "HtmlBlock", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1509:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HtmlBlock", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_BulletList(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "BulletList")); - { int yypos1516= G->pos, yythunkpos1516= G->thunkpos; if (!yy_Bullet(G)) { goto l1515; } G->pos= yypos1516; G->thunkpos= yythunkpos1516; - } - { int yypos1517= G->pos, yythunkpos1517= G->thunkpos; if (!yy_ListTight(G)) { goto l1518; } goto l1517; - l1518:; G->pos= yypos1517; G->thunkpos= yythunkpos1517; if (!yy_ListLoose(G)) { goto l1515; } - } - l1517:; - yyprintf((stderr, " ok %s @ %s\n", "BulletList", G->buf+G->pos)); - return 1; - l1515:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "BulletList", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_OrderedList(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "OrderedList")); - { int yypos1520= G->pos, yythunkpos1520= G->thunkpos; if (!yy_Enumerator(G)) { goto l1519; } G->pos= yypos1520; G->thunkpos= yythunkpos1520; - } - { int yypos1521= G->pos, yythunkpos1521= G->thunkpos; if (!yy_ListTight(G)) { goto l1522; } goto l1521; - l1522:; G->pos= yypos1521; G->thunkpos= yythunkpos1521; if (!yy_ListLoose(G)) { goto l1519; } - } - l1521:; - yyprintf((stderr, " ok %s @ %s\n", "OrderedList", G->buf+G->pos)); - return 1; - l1519:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "OrderedList", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Heading(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Heading")); - { int yypos1524= G->pos, yythunkpos1524= G->thunkpos; if (!yy_SetextHeading(G)) { goto l1525; } goto l1524; - l1525:; G->pos= yypos1524; G->thunkpos= yythunkpos1524; if (!yy_AtxHeading(G)) { goto l1523; } - } - l1524:; - yyprintf((stderr, " ok %s @ %s\n", "Heading", G->buf+G->pos)); - return 1; - l1523:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Heading", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_HorizontalRule(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "HorizontalRule")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1526; if (!yy_NonindentSpace(G)) { goto l1526; } - { int yypos1527= G->pos, yythunkpos1527= G->thunkpos; if (!yymatchChar(G, '*')) goto l1528; if (!yy_Sp(G)) { goto l1528; } if (!yymatchChar(G, '*')) goto l1528; if (!yy_Sp(G)) { goto l1528; } if (!yymatchChar(G, '*')) goto l1528; - l1529:; - { int yypos1530= G->pos, yythunkpos1530= G->thunkpos; if (!yy_Sp(G)) { goto l1530; } if (!yymatchChar(G, '*')) goto l1530; goto l1529; - l1530:; G->pos= yypos1530; G->thunkpos= yythunkpos1530; - } goto l1527; - l1528:; G->pos= yypos1527; G->thunkpos= yythunkpos1527; if (!yymatchChar(G, '-')) goto l1531; if (!yy_Sp(G)) { goto l1531; } if (!yymatchChar(G, '-')) goto l1531; if (!yy_Sp(G)) { goto l1531; } if (!yymatchChar(G, '-')) goto l1531; - l1532:; - { int yypos1533= G->pos, yythunkpos1533= G->thunkpos; if (!yy_Sp(G)) { goto l1533; } if (!yymatchChar(G, '-')) goto l1533; goto l1532; - l1533:; G->pos= yypos1533; G->thunkpos= yythunkpos1533; - } goto l1527; - l1531:; G->pos= yypos1527; G->thunkpos= yythunkpos1527; if (!yymatchChar(G, '_')) goto l1526; if (!yy_Sp(G)) { goto l1526; } if (!yymatchChar(G, '_')) goto l1526; if (!yy_Sp(G)) { goto l1526; } if (!yymatchChar(G, '_')) goto l1526; - l1534:; - { int yypos1535= G->pos, yythunkpos1535= G->thunkpos; if (!yy_Sp(G)) { goto l1535; } if (!yymatchChar(G, '_')) goto l1535; goto l1534; - l1535:; G->pos= yypos1535; G->thunkpos= yythunkpos1535; - } - } - l1527:; if (!yy_Sp(G)) { goto l1526; } if (!yy_Newline(G)) { goto l1526; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1526; if (!yy_BlankLine(G)) { goto l1526; } - l1536:; - { int yypos1537= G->pos, yythunkpos1537= G->thunkpos; if (!yy_BlankLine(G)) { goto l1537; } goto l1536; - l1537:; G->pos= yypos1537; G->thunkpos= yythunkpos1537; - } yyDo(G, yy_1_HorizontalRule, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "HorizontalRule", G->buf+G->pos)); - return 1; - l1526:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HorizontalRule", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Reference(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 3, 0); - yyprintf((stderr, "%s\n", "Reference")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1538; if (!yy_LocMarker(G)) { goto l1538; } yyDo(G, yySet, -3, 0); if (!yy_NonindentSpace(G)) { goto l1538; } - { int yypos1539= G->pos, yythunkpos1539= G->thunkpos; if (!yymatchString(G, "[]")) goto l1539; goto l1538; - l1539:; G->pos= yypos1539; G->thunkpos= yythunkpos1539; - } if (!yy_Label(G)) { goto l1538; } yyDo(G, yySet, -2, 0); if (!yymatchChar(G, ':')) goto l1538; if (!yy_Spnl(G)) { goto l1538; } if (!yy_RefSrc(G)) { goto l1538; } yyDo(G, yySet, -1, 0); if (!yy_RefTitle(G)) { goto l1538; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1538; if (!yy_BlankLine(G)) { goto l1538; } - l1540:; - { int yypos1541= G->pos, yythunkpos1541= G->thunkpos; if (!yy_BlankLine(G)) { goto l1541; } goto l1540; - l1541:; G->pos= yypos1541; G->thunkpos= yythunkpos1541; - } yyDo(G, yy_1_Reference, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Reference", G->buf+G->pos)); yyDo(G, yyPop, 3, 0); - return 1; - l1538:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Reference", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Note(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Note")); yyText(G, G->begin, G->end); if (!( EXT(pmh_EXT_NOTES) )) goto l1542; if (!yy_NonindentSpace(G)) { goto l1542; } if (!yy_RawNoteReference(G)) { goto l1542; } if (!yymatchChar(G, ':')) goto l1542; if (!yy_Sp(G)) { goto l1542; } if (!yy_RawNoteBlock(G)) { goto l1542; } - l1543:; - { int yypos1544= G->pos, yythunkpos1544= G->thunkpos; - { int yypos1545= G->pos, yythunkpos1545= G->thunkpos; if (!yy_Indent(G)) { goto l1544; } G->pos= yypos1545; G->thunkpos= yythunkpos1545; - } if (!yy_RawNoteBlock(G)) { goto l1544; } goto l1543; - l1544:; G->pos= yypos1544; G->thunkpos= yythunkpos1544; - } - yyprintf((stderr, " ok %s @ %s\n", "Note", G->buf+G->pos)); - return 1; - l1542:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Note", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Verbatim(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "Verbatim")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l1546; if (!yy_LocMarker(G)) { goto l1546; } yyDo(G, yySet, -1, 0); if (!yy_VerbatimChunk(G)) { goto l1546; } - l1547:; - { int yypos1548= G->pos, yythunkpos1548= G->thunkpos; if (!yy_VerbatimChunk(G)) { goto l1548; } goto l1547; - l1548:; G->pos= yypos1548; G->thunkpos= yythunkpos1548; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l1546; yyDo(G, yy_1_Verbatim, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "Verbatim", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1546:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Verbatim", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_BlockQuote(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; yyDo(G, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "BlockQuote")); if (!yy_BlockQuoteRaw(G)) { goto l1549; } yyDo(G, yySet, -1, 0); yyDo(G, yy_1_BlockQuote, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "BlockQuote", G->buf+G->pos)); yyDo(G, yyPop, 1, 0); - return 1; - l1549:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "BlockQuote", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_BlankLine(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "BlankLine")); if (!yy_Sp(G)) { goto l1550; } if (!yy_Newline(G)) { goto l1550; } - yyprintf((stderr, " ok %s @ %s\n", "BlankLine", G->buf+G->pos)); - return 1; - l1550:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "BlankLine", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_LocMarker(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "LocMarker")); - { int yypos1552= G->pos, yythunkpos1552= G->thunkpos; if (!yymatchDot(G)) goto l1551; G->pos= yypos1552; G->thunkpos= yythunkpos1552; - } yyDo(G, yy_1_LocMarker, G->begin, G->end); - yyprintf((stderr, " ok %s @ %s\n", "LocMarker", G->buf+G->pos)); - return 1; - l1551:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "LocMarker", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Block(GREG *G) -{ int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "Block")); - l1554:; - { int yypos1555= G->pos, yythunkpos1555= G->thunkpos; if (!yy_BlankLine(G)) { goto l1555; } goto l1554; - l1555:; G->pos= yypos1555; G->thunkpos= yythunkpos1555; - } - { int yypos1556= G->pos, yythunkpos1556= G->thunkpos; if (!yy_BlockQuote(G)) { goto l1557; } goto l1556; - l1557:; G->pos= yypos1556; G->thunkpos= yythunkpos1556; if (!yy_Verbatim(G)) { goto l1558; } goto l1556; - l1558:; G->pos= yypos1556; G->thunkpos= yythunkpos1556; if (!yy_Note(G)) { goto l1559; } goto l1556; - l1559:; G->pos= yypos1556; G->thunkpos= yythunkpos1556; if (!yy_Reference(G)) { goto l1560; } goto l1556; - l1560:; G->pos= yypos1556; G->thunkpos= yythunkpos1556; if (!yy_HorizontalRule(G)) { goto l1561; } goto l1556; - l1561:; G->pos= yypos1556; G->thunkpos= yythunkpos1556; if (!yy_Heading(G)) { goto l1562; } goto l1556; - l1562:; G->pos= yypos1556; G->thunkpos= yythunkpos1556; if (!yy_OrderedList(G)) { goto l1563; } goto l1556; - l1563:; G->pos= yypos1556; G->thunkpos= yythunkpos1556; if (!yy_BulletList(G)) { goto l1564; } goto l1556; - l1564:; G->pos= yypos1556; G->thunkpos= yythunkpos1556; if (!yy_HtmlBlock(G)) { goto l1565; } goto l1556; - l1565:; G->pos= yypos1556; G->thunkpos= yythunkpos1556; if (!yy_StyleBlock(G)) { goto l1566; } goto l1556; - l1566:; G->pos= yypos1556; G->thunkpos= yythunkpos1556; if (!yy_Para(G)) { goto l1567; } goto l1556; - l1567:; G->pos= yypos1556; G->thunkpos= yythunkpos1556; if (!yy_Plain(G)) { goto l1553; } - } - l1556:; - yyprintf((stderr, " ok %s @ %s\n", "Block", G->buf+G->pos)); - return 1; - l1553:; G->pos= yypos0; G->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Block", G->buf+G->pos)); - return 0; -} -YY_RULE(int) yy_Doc(GREG *G) -{ - yyprintf((stderr, "%s\n", "Doc")); - l1569:; - { int yypos1570= G->pos, yythunkpos1570= G->thunkpos; if (!yy_Block(G)) { goto l1570; } goto l1569; - l1570:; G->pos= yypos1570; G->thunkpos= yythunkpos1570; - } - yyprintf((stderr, " ok %s @ %s\n", "Doc", G->buf+G->pos)); - return 1; -} - -#ifndef YY_PART - -typedef int (*yyrule)(GREG *G); - -YY_PARSE(int) YY_NAME(parse_from)(GREG *G, yyrule yystart) -{ - int yyok; - if (!G->buflen) - { - G->buflen= YY_BUFFER_START_SIZE; - G->buf= (char *)YY_ALLOC(G->buflen, G->data); - G->textlen= YY_BUFFER_START_SIZE; - G->text= (char *)YY_ALLOC(G->textlen, G->data); - G->thunkslen= YY_STACK_SIZE; - G->thunks= (yythunk *)YY_ALLOC(sizeof(yythunk) * G->thunkslen, G->data); - G->valslen= YY_STACK_SIZE; - G->vals= (YYSTYPE*)YY_ALLOC(sizeof(YYSTYPE) * G->valslen, G->data); - G->begin= G->end= G->pos= G->limit= G->thunkpos= 0; - } - G->pos = 0; - G->begin= G->end= G->pos; - G->thunkpos= 0; - G->val= G->vals; - yyok= yystart(G); - if (yyok) yyDone(G); - yyCommit(G); - return yyok; - (void)yyrefill(NULL); - (void)yymatchDot(NULL); - (void)yymatchChar(NULL, 0); - (void)yymatchString(NULL, NULL); - (void)yymatchClass(NULL, NULL); - (void)yyDo(NULL, NULL, 0, 0); - (void)yyText(NULL, 0, 0); - (void)yyDone(NULL); - (void)yyCommit(NULL); - (void)yyAccept(NULL, 0); - (void)yyPush(NULL, NULL, 0, NULL, NULL); - (void)yyPop(NULL, NULL, 0, NULL, NULL); - (void)yySet(NULL, NULL, 0, NULL, NULL); -} - -YY_PARSE(int) YY_NAME(parse)(GREG *G) -{ - return YY_NAME(parse_from)(G, yy_Doc); -} - -YY_PARSE(GREG *) YY_NAME(parse_new)(YY_XTYPE data) -{ - GREG *G = (GREG *)YY_CALLOC(1, sizeof(GREG), G->data); - G->data = data; - return G; -} - -YY_PARSE(void) YY_NAME(parse_free)(GREG *G) -{ - YY_FREE(G->buf); - YY_FREE(G->text); - YY_FREE(G->thunks); - YY_FREE(G->vals); - YY_FREE(G); -} - -#endif - - - - -/* PEG Markdown Highlight - * Copyright 2011-2013 Ali Rantakari -- http://hasseg.org - * Licensed under the GPL2+ and MIT licenses (see LICENSE for more info). - * - * pmh_parser_foot.c - * - * Code to be appended to the end of the parser code generated from the - * PEG grammar. - */ - - -static void _parse(parser_data *p_data, yyrule start_rule) -{ - GREG *g = YY_NAME(parse_new)(p_data); - if (start_rule == NULL) - YY_NAME(parse)(g); - else - YY_NAME(parse_from)(g, start_rule); - YY_NAME(parse_free)(g); - - pmh_PRINTF("\n\n"); -} - -static void parse_markdown(parser_data *p_data) -{ - pmh_PRINTF("\nPARSING DOCUMENT: "); - - _parse(p_data, NULL); -} - -static void parse_references(parser_data *p_data) -{ - pmh_PRINTF("\nPARSING REFERENCES: "); - - p_data->parsing_only_references = true; - _parse(p_data, yy_References); - p_data->parsing_only_references = false; - - p_data->references = p_data->head_elems[pmh_REFERENCE]; - p_data->head_elems[pmh_REFERENCE] = NULL; -} - -#pragma clang diagnostic pop diff --git a/Sources/CPegMarkdown/pmh_styleparser.c b/Sources/CPegMarkdown/pmh_styleparser.c deleted file mode 100644 index 3ad4737..0000000 --- a/Sources/CPegMarkdown/pmh_styleparser.c +++ /dev/null @@ -1,929 +0,0 @@ -/* PEG Markdown Highlight - * Copyright 2011-2013 Ali Rantakari -- http://hasseg.org - * Licensed under the GPL2+ and MIT licenses (see LICENSE for more info). - * - * styleparser.c - * - * Parser for custom syntax highlighting stylesheets. - */ - -#include -#include -#include -#include -#include - -#include "pmh_styleparser.h" -#include "pmh_parser.h" - - -#if pmh_DEBUG_OUTPUT -#define pmhsp_PRINTF(x, ...) fprintf(stderr, x, ##__VA_ARGS__) -#else -#define pmhsp_PRINTF(x, ...) -#endif - - -// vasprintf is not in the C standard nor in POSIX so we provide our own -static int our_vasprintf(char **strptr, const char *fmt, va_list argptr) -{ - int ret; - va_list argptr2; - *strptr = NULL; - - va_copy(argptr2, argptr); - ret = vsnprintf(NULL, 0, fmt, argptr2); - if (ret <= 0) - return ret; - - *strptr = (char *)malloc(ret+1); - if (*strptr == NULL) - return -1; - - va_copy(argptr2, argptr); - ret = vsnprintf(*strptr, ret+1, fmt, argptr2); - - return ret; -} - - - -// Parsing context data -typedef struct -{ - char *input; - void (*error_callback)(char*,int,void*); - void *error_callback_context; - int styles_pos; - pmh_style_collection *styles; -} style_parser_data; - -typedef struct raw_attribute -{ - char *name; - char *value; - int line_number; - struct raw_attribute *next; -} raw_attribute; - -static raw_attribute *new_raw_attribute(char *name, char *value, - int line_number) -{ - raw_attribute *v = (raw_attribute *)malloc(sizeof(raw_attribute)); - v->name = name; - v->value = value; - v->line_number = line_number; - v->next = NULL; - return v; -} - -static void free_raw_attributes(raw_attribute *list) -{ - raw_attribute *cur = list; - while (cur != NULL) - { - if (cur->name != NULL) free(cur->name); - if (cur->value != NULL) free(cur->value); - raw_attribute *this = cur; - cur = cur->next; - free(this); - } -} - - -static void report_error(style_parser_data *p_data, - int line_number, char *str, ...) -{ - if (p_data->error_callback == NULL) - return; - va_list argptr; - va_start(argptr, str); - char *errmsg; - our_vasprintf(&errmsg, str, argptr); - va_end(argptr); - p_data->error_callback(errmsg, line_number, - p_data->error_callback_context); - free(errmsg); -} - - - -static char *trim_str(char *str) -{ - while (isspace(*str)) - str++; - if (*str == '\0') - return str; - char *end = str + strlen(str) - 1; - while (end > str && isspace(*end)) - end--; - *(end+1) = '\0'; - return str; -} - -static char *trim_str_dup(char *str) -{ - size_t start = 0; - while (isspace(*(str + start))) - start++; - size_t end = strlen(str) - 1; - while (start < end && isspace(*(str + end))) - end--; - - size_t len = end - start + 1; - char *ret = (char *)malloc(sizeof(char)*len + 1); - *ret = '\0'; - strncat(ret, (str + start), len); - - return ret; -} - -static char *strcpy_lower(char *str) -{ - char *low = strdup(str); - int i; - int len = strlen(str); - for (i = 0; i < len; i++) - *(low+i) = tolower(*(low+i)); - return low; -} - -static char *standardize_str(char *str) -{ - return strcpy_lower(trim_str(str)); -} - - - - -static pmh_attr_argb_color *new_argb_color(int r, int g, int b, int a) -{ - pmh_attr_argb_color *c = (pmh_attr_argb_color *) - malloc(sizeof(pmh_attr_argb_color)); - c->red = r; c->green = g; c->blue = b; c->alpha = a; - return c; -} -static pmh_attr_argb_color *new_argb_from_hex(long long hex, bool has_alpha) -{ - // 0xaarrggbb - int a = has_alpha ? ((hex >> 24) & 0xFF) : 255; - int r = ((hex >> 16) & 0xFF); - int g = ((hex >> 8) & 0xFF); - int b = (hex & 0xFF); - return new_argb_color(r,g,b,a); -} -static pmh_attr_argb_color *new_argb_from_hex_str(style_parser_data *p_data, - int attr_line_number, - char *str) -{ - // "aarrggbb" - int len = strlen(str); - if (len != 6 && len != 8) { - report_error(p_data, attr_line_number, - "Value '%s' is not a valid color value: it should be a " - "hexadecimal number, 6 or 8 characters long.", - str); - return NULL; - } - char *endptr = NULL; - long long num = strtoll(str, &endptr, 16); - if (*endptr != '\0') { - report_error(p_data, attr_line_number, - "Value '%s' is not a valid color value: the character " - "'%c' is invalid. The color value should be a hexadecimal " - "number, 6 or 8 characters long.", - str, *endptr); - return NULL; - } - return new_argb_from_hex(num, (len == 8)); -} - -static pmh_attr_value *new_attr_value() -{ - return (pmh_attr_value *)malloc(sizeof(pmh_attr_value)); -} - -static pmh_attr_font_styles *new_font_styles() -{ - pmh_attr_font_styles *ret = (pmh_attr_font_styles *) - malloc(sizeof(pmh_attr_font_styles)); - ret->italic = false; - ret->bold = false; - ret->underlined = false; - return ret; -} - -static pmh_attr_font_size *new_font_size() -{ - pmh_attr_font_size *ret = (pmh_attr_font_size *) - malloc(sizeof(pmh_attr_font_size)); - ret->is_relative = false; - ret->size_pt = 0; - return ret; -} - -static pmh_style_attribute *new_attr(char *name, pmh_attr_type type) -{ - pmh_style_attribute *attr = (pmh_style_attribute *)malloc(sizeof(pmh_style_attribute)); - attr->name = strdup(name); - attr->type = type; - attr->next = NULL; - return attr; -} - -static void free_style_attributes(pmh_style_attribute *list) -{ - pmh_style_attribute *cur = list; - while (cur != NULL) - { - if (cur->name != NULL) - free(cur->name); - if (cur->value != NULL) - { - if (cur->type == pmh_attr_type_foreground_color - || cur->type == pmh_attr_type_background_color - || cur->type == pmh_attr_type_caret_color) - free(cur->value->argb_color); - else if (cur->type == pmh_attr_type_font_family) - free(cur->value->font_family); - else if (cur->type == pmh_attr_type_font_style) - free(cur->value->font_styles); - else if (cur->type == pmh_attr_type_font_size_pt) - free(cur->value->font_size); - else if (cur->type == pmh_attr_type_other) - free(cur->value->string); - free(cur->value); - } - pmh_style_attribute *this = cur; - cur = cur->next; - free(this); - } -} - - - - - -#define IF_ATTR_NAME(x) if (strcmp(x, name) == 0) -pmh_attr_type pmh_attr_type_from_name(char *name) -{ - IF_ATTR_NAME("color") return pmh_attr_type_foreground_color; - else IF_ATTR_NAME("foreground") return pmh_attr_type_foreground_color; - else IF_ATTR_NAME("foreground-color") return pmh_attr_type_foreground_color; - else IF_ATTR_NAME("background") return pmh_attr_type_background_color; - else IF_ATTR_NAME("background-color") return pmh_attr_type_background_color; - else IF_ATTR_NAME("caret") return pmh_attr_type_caret_color; - else IF_ATTR_NAME("caret-color") return pmh_attr_type_caret_color; - else IF_ATTR_NAME("font-size") return pmh_attr_type_font_size_pt; - else IF_ATTR_NAME("font-family") return pmh_attr_type_font_family; - else IF_ATTR_NAME("font-style") return pmh_attr_type_font_style; - return pmh_attr_type_other; -} - -char *pmh_attr_name_from_type(pmh_attr_type type) -{ - switch (type) - { - case pmh_attr_type_foreground_color: - return "foreground-color"; break; - case pmh_attr_type_background_color: - return "background-color"; break; - case pmh_attr_type_caret_color: - return "caret-color"; break; - case pmh_attr_type_font_size_pt: - return "font-size"; break; - case pmh_attr_type_font_family: - return "font-family"; break; - case pmh_attr_type_font_style: - return "font-style"; break; - default: - return "unknown"; - } -} - - -typedef struct multi_value -{ - char *value; - size_t length; - int line_number; - struct multi_value *next; -} multi_value; - -static multi_value *split_multi_value(char *input, char separator) -{ - multi_value *head = NULL; - multi_value *tail = NULL; - - char *c = input; - while (*c != '\0') - { - size_t i; - for (i = 0; (*(c+i) != '\0' && *(c+i) != separator); i++); - - multi_value *mv = (multi_value *)malloc(sizeof(multi_value)); - mv->value = (char *)malloc(sizeof(char)*i + 1); - mv->length = i; - mv->line_number = 0; - mv->next = NULL; - *mv->value = '\0'; - strncat(mv->value, c, i); - - if (head == NULL) { - head = mv; - tail = mv; - } else { - tail->next = mv; - tail = mv; - } - - if (*(c+i) == separator) - i++; - c += i; - } - - return head; -} - -static void free_multi_value(multi_value *val) -{ - multi_value *cur = val; - while (cur != NULL) - { - multi_value *this = cur; - multi_value *next_cur = cur->next; - free(this->value); - free(this); - cur = next_cur; - } -} - - - - -#define EQUALS(a,b) (strcmp(a, b) == 0) - -static pmh_style_attribute *interpret_attributes(style_parser_data *p_data, - pmh_element_type lang_element_type, - raw_attribute *raw_attributes) -{ - pmh_style_attribute *attrs = NULL; - - raw_attribute *cur = raw_attributes; - while (cur != NULL) - { - pmh_attr_type atype = pmh_attr_type_from_name(cur->name); - pmh_style_attribute *attr = new_attr(cur->name, atype); - attr->lang_element_type = lang_element_type; - attr->value = new_attr_value(); - - if (atype == pmh_attr_type_foreground_color - || atype == pmh_attr_type_background_color - || atype == pmh_attr_type_caret_color) - { - char *hexstr = trim_str(cur->value); - // new_argb_from_hex_str() reports conversion errors - attr->value->argb_color = - new_argb_from_hex_str(p_data, cur->line_number, hexstr); - if (attr->value->argb_color == NULL) { - free_style_attributes(attr); - attr = NULL; - } - } - else if (atype == pmh_attr_type_font_size_pt) - { - pmh_attr_font_size *fs = new_font_size(); - attr->value->font_size = fs; - - char *trimmed_value = trim_str_dup(cur->value); - - fs->is_relative = (*trimmed_value == '+' || *trimmed_value == '-'); - char *endptr = NULL; - fs->size_pt = (int)strtol(cur->value, &endptr, 10); - if (endptr == cur->value) { - report_error(p_data, cur->line_number, - "Value '%s' is invalid for attribute '%s'", - cur->value, cur->name); - free_style_attributes(attr); - attr = NULL; - } - - free(trimmed_value); - } - else if (atype == pmh_attr_type_font_family) - { - attr->value->font_family = trim_str_dup(cur->value); - } - else if (atype == pmh_attr_type_font_style) - { - attr->value->font_styles = new_font_styles(); - multi_value *values = split_multi_value(cur->value, ','); - multi_value *value_cur = values; - while (value_cur != NULL) - { - char *standardized_value = standardize_str(value_cur->value); - - if (EQUALS(standardized_value, "italic")) - attr->value->font_styles->italic = true; - else if (EQUALS(standardized_value, "bold")) - attr->value->font_styles->bold = true; - else if (EQUALS(standardized_value, "underlined")) - attr->value->font_styles->underlined = true; - else { - report_error(p_data, cur->line_number, - "Value '%s' is invalid for attribute '%s'", - standardized_value, cur->name); - } - - free(standardized_value); - value_cur = value_cur->next; - } - free_multi_value(values); - } - else if (atype == pmh_attr_type_other) - { - attr->value->string = trim_str_dup(cur->value); - } - - if (attr != NULL) { - // add to linked list - attr->next = attrs; - attrs = attr; - } - - cur = cur->next; - } - - return attrs; -} - - -static void interpret_and_add_style(style_parser_data *p_data, - char *style_rule_name, - int style_rule_line_number, - raw_attribute *raw_attributes) -{ - bool isEditorType = false; - bool isCurrentLineType = false; - bool isSelectionType = false; - pmh_element_type type = pmh_element_type_from_name(style_rule_name); - if (type == pmh_NO_TYPE) - { - if (EQUALS(style_rule_name, "editor")) { - isEditorType = true; - type = pmh_NO_TYPE; - } else if (EQUALS(style_rule_name, "editor-current-line")) { - isCurrentLineType = true; - type = pmh_NO_TYPE; - } else if (EQUALS(style_rule_name, "editor-selection")) { - isSelectionType = true; - type = pmh_NO_TYPE; - } else { - report_error(p_data, style_rule_line_number, - "Style rule '%s' is not a language element type name or " - "one of the following: 'editor', 'editor-current-line', " - "'editor-selection'", - style_rule_name); - return; - } - } - pmh_style_attribute *attrs = interpret_attributes(p_data, type, raw_attributes); - if (isEditorType) - p_data->styles->editor_styles = attrs; - else if (isCurrentLineType) - p_data->styles->editor_current_line_styles = attrs; - else if (isSelectionType) - p_data->styles->editor_selection_styles = attrs; - else - p_data->styles->element_styles[(p_data->styles_pos)++] = attrs; -} - - - - - - - -static bool char_is_whitespace(char c) -{ - return (c == ' ' || c == '\t'); -} - -static bool char_begins_linecomment(char c) -{ - return (c == '#'); -} - -static bool line_is_comment(multi_value *line) -{ - char *c; - for (c = line->value; *c != '\0'; c++) - { - if (!char_is_whitespace(*c)) - return char_begins_linecomment(*c); - } - return false; -} - -static bool line_is_empty(multi_value *line) -{ - char *c; - for (c = line->value; *c != '\0'; c++) - { - if (!char_is_whitespace(*c)) - return false; - } - return true; -} - - - -typedef struct block -{ - multi_value *lines; - struct block *next; -} block; - -static block *new_block() -{ - block *ret = (block *)malloc(sizeof(block)); - ret->next = NULL; - ret->lines = NULL; - return ret; -} - -static void free_blocks(block *val) -{ - block *cur = val; - while (cur != NULL) - { - block *this = cur; - block *next = this->next; - free_multi_value(this->lines); - free(this); - cur = next; - } -} - -static block *get_blocks(char *input) -{ - block *head = NULL; - block *tail = NULL; - block *current_block = NULL; - - multi_value *discarded_lines = NULL; - - int line_number_counter = 1; - - multi_value *lines = split_multi_value(input, '\n'); - multi_value *previous_line = NULL; - multi_value *line_cur = lines; - while (line_cur != NULL) - { - bool discard_line = false; - - line_cur->line_number = line_number_counter++; - - if (line_is_empty(line_cur)) - { - discard_line = true; - - if (current_block != NULL) - { - // terminate block - if (tail != current_block) - tail->next = current_block; - tail = current_block; - current_block = NULL; - previous_line->next = NULL; - } - } - else if (line_is_comment(line_cur)) - { - // Do not discard (i.e. free()) comment lines within blocks: - if (current_block == NULL) - discard_line = true; - } - else - { - if (current_block == NULL) - { - // start block - current_block = new_block(); - current_block->lines = line_cur; - if (previous_line != NULL) - previous_line->next = NULL; - } - if (head == NULL) { - head = current_block; - tail = current_block; - } - } - - multi_value *next_cur = line_cur->next; - previous_line = (discard_line) ? NULL : line_cur; - - if (discard_line) { - line_cur->next = discarded_lines; - discarded_lines = line_cur; - } - - line_cur = next_cur; - } - - if (current_block != NULL && tail != current_block) - tail->next = current_block; - - free_multi_value(discarded_lines); - - return head; -} - - -#define ASSIGNMENT_OP_UITEXT "':' or '='" -#define IS_ASSIGNMENT_OP(c) ((c) == ':' || (c) == '=') -#define IS_STYLE_RULE_NAME_CHAR(c) \ - ( (c) != '\0' && !isspace(c) \ - && !char_begins_linecomment(c) && !IS_ASSIGNMENT_OP(c) ) -#define IS_ATTRIBUTE_NAME_CHAR(c) \ - ( (c) != '\0' && !char_begins_linecomment(c) && !IS_ASSIGNMENT_OP(c) ) -#define IS_ATTRIBUTE_VALUE_CHAR(c) \ - ( (c) != '\0' && !char_begins_linecomment(c) ) - -static char *get_style_rule_name(multi_value *line) -{ - char *str = line->value; - - // Scan past leading whitespace: - size_t start_index; - for (start_index = 0; - (*(str+start_index) != '\0' && isspace(*(str+start_index))); - start_index++); - - // Scan until style rule name characters end: - size_t value_end_index; - for (value_end_index = start_index; - IS_STYLE_RULE_NAME_CHAR(*(str + value_end_index)); - value_end_index++); - - // Copy style rule name: - size_t value_len = value_end_index - start_index; - char *value = (char *)malloc(sizeof(char)*value_len + 1); - *value = '\0'; - strncat(value, (str + start_index), value_len); - - return value; -} - -static bool parse_attribute_line(style_parser_data *p_data, multi_value *line, - char **out_attr_name, char **out_attr_value) -{ - char *str = line->value; - - // Scan past leading whitespace: - size_t name_start_index; - for (name_start_index = 0; - ( *(str+name_start_index) != '\0' && - isspace(*(str+name_start_index)) ); - name_start_index++); - - // Scan until attribute name characters end: - size_t name_end_index; - for (name_end_index = name_start_index; - IS_ATTRIBUTE_NAME_CHAR(*(str + name_end_index)); - name_end_index++); - // Scan backwards to trim trailing whitespace off: - while (name_start_index < name_end_index - && isspace(*(str + name_end_index - 1))) - name_end_index--; - - // Scan until just after the first assignment operator: - size_t assignment_end_index; - for (assignment_end_index = name_end_index; - ( *(str + assignment_end_index) != '\0' && - !IS_ASSIGNMENT_OP(*(str + assignment_end_index)) ); - assignment_end_index++); - - // Scan over the found assignment operator, or report error: - if (IS_ASSIGNMENT_OP(*(str + assignment_end_index))) - assignment_end_index++; - else - { - report_error(p_data, line->line_number, - "Invalid attribute definition: str does not contain " - "an assignment operator (%s): '%s'", - ASSIGNMENT_OP_UITEXT, str); - return false; - } - - size_t value_start_index = assignment_end_index; - // Scan until attribute value characters end: - size_t value_end_index; - for (value_end_index = value_start_index; - IS_ATTRIBUTE_VALUE_CHAR(*(str + value_end_index)); - value_end_index++); - - // Copy attribute name: - size_t name_len = name_end_index - name_start_index; - char *attr_name = (char *)malloc(sizeof(char)*name_len + 1); - *attr_name = '\0'; - strncat(attr_name, (str + name_start_index), name_len); - *out_attr_name = attr_name; - - // Copy attribute value: - size_t attr_value_len = value_end_index - assignment_end_index; - char *attr_value_str = (char *)malloc(sizeof(char)*attr_value_len + 1); - *attr_value_str = '\0'; - strncat(attr_value_str, (str + assignment_end_index), attr_value_len); - *out_attr_value = attr_value_str; - - return true; -} - - -#define HAS_UTF8_BOM(x) ( ((*x & 0xFF) == 0xEF)\ - && ((*(x+1) & 0xFF) == 0xBB)\ - && ((*(x+2) & 0xFF) == 0xBF) ) - -// - Removes UTF-8 BOM -// - Standardizes line endings to \n -static char *strcpy_preformat_style(char *str) -{ - char *new_str = (char *)malloc(sizeof(char) * strlen(str) + 1); - - char *c = str; - int i = 0; - - if (HAS_UTF8_BOM(c)) - c += 3; - - while (*c != '\0') - { - if (*c == '\r' && *(c+1) == '\n') - { - *(new_str+i) = '\n'; - i++; - c += 2; - } - else if (*c == '\r') - { - *(new_str+i) = '\n'; - i++; - c++; - } - else - { - *(new_str+i) = *c; - i++; - c++; - } - } - *(new_str+i) = '\0'; - - return new_str; -} - - - -static void _sty_parse(style_parser_data *p_data) -{ - // We don't have to worry about leaking the original p_data->input; - // the user of the library is responsible for that: - p_data->input = strcpy_preformat_style(p_data->input); - - block *blocks = get_blocks(p_data->input); - - block *block_cur = blocks; - while (block_cur != NULL) - { - pmhsp_PRINTF("Block:\n"); - multi_value *header_line = block_cur->lines; - if (header_line == NULL) { - block_cur = block_cur->next; - continue; - } - - pmhsp_PRINTF(" Head line (len %ld): '%s'\n", - header_line->length, header_line->value); - char *style_rule_name = get_style_rule_name(header_line); - pmhsp_PRINTF(" Style rule name: '%s'\n", style_rule_name); - - multi_value *attr_line_cur = header_line->next; - if (attr_line_cur == NULL) - report_error(p_data, header_line->line_number, - "No style attributes defined for style rule '%s'", - style_rule_name); - - raw_attribute *attributes_head = NULL; - raw_attribute *attributes_tail = NULL; - - while (attr_line_cur != NULL) - { - if (line_is_comment(attr_line_cur)) - { - attr_line_cur = attr_line_cur->next; - continue; - } - - pmhsp_PRINTF(" Attr line (len %ld): '%s'\n", - attr_line_cur->length, attr_line_cur->value); - char *attr_name_str; - char *attr_value_str; - bool success = parse_attribute_line(p_data, - attr_line_cur, - &attr_name_str, - &attr_value_str); - if (success) - { - pmhsp_PRINTF(" Attr: '%s' Value: '%s'\n", - attr_name_str, attr_value_str); - raw_attribute *attribute = - new_raw_attribute(attr_name_str, attr_value_str, - attr_line_cur->line_number); - if (attributes_head == NULL) { - attributes_head = attribute; - attributes_tail = attribute; - } else { - attributes_tail->next = attribute; - attributes_tail = attribute; - } - } - - attr_line_cur = attr_line_cur->next; - } - - if (attributes_head != NULL) - { - interpret_and_add_style(p_data, style_rule_name, - header_line->line_number, attributes_head); - free_raw_attributes(attributes_head); - } - - free(style_rule_name); - - block_cur = block_cur->next; - } - - free_blocks(blocks); - free(p_data->input); -} - - - -static pmh_style_collection *new_style_collection() -{ - pmh_style_collection *sc = (pmh_style_collection *) - malloc(sizeof(pmh_style_collection)); - - sc->element_styles = (pmh_style_attribute**) - malloc(sizeof(pmh_style_attribute*) - * pmh_NUM_LANG_TYPES); - int i; - for (i = 0; i < pmh_NUM_LANG_TYPES; i++) - sc->element_styles[i] = NULL; - - sc->editor_styles = NULL; - sc->editor_current_line_styles = NULL; - sc->editor_selection_styles = NULL; - - return sc; -} - -void pmh_free_style_collection(pmh_style_collection *coll) -{ - free_style_attributes(coll->editor_styles); - free_style_attributes(coll->editor_current_line_styles); - free_style_attributes(coll->editor_selection_styles); - int i; - for (i = 0; i < pmh_NUM_LANG_TYPES; i++) - free_style_attributes(coll->element_styles[i]); - free(coll->element_styles); - free(coll); -} - -static style_parser_data *new_style_parser_data(char *input) -{ - style_parser_data *p_data = (style_parser_data*) - malloc(sizeof(style_parser_data)); - p_data->input = input; - p_data->styles_pos = 0; - p_data->styles = new_style_collection(); - return p_data; -} - -pmh_style_collection *pmh_parse_styles(char *input, - void(*error_callback)(char*,int,void*), - void *error_callback_context) -{ - style_parser_data *p_data = new_style_parser_data(input); - p_data->error_callback = error_callback; - p_data->error_callback_context = error_callback_context; - - _sty_parse(p_data); - - pmh_style_collection *ret = p_data->styles; - free(p_data); - return ret; -} - - diff --git a/Sources/MacDownKit/App/MacDownCommands.swift b/Sources/MacDownKit/App/MacDownCommands.swift index c6c9210..53139a0 100644 --- a/Sources/MacDownKit/App/MacDownCommands.swift +++ b/Sources/MacDownKit/App/MacDownCommands.swift @@ -39,9 +39,9 @@ public struct MacDownCommands: Commands { ToolbarCommands() // SwiftUI's Edit menu has no Paste and Match Style, the way to paste - // plain text when Paste converts formatting (paste intent, FR-4). + // plain text when Paste converts formatting. // With "Convert formatted text to Markdown when pasting" off, Paste - // pastes plain text and Paste as Markdown converts (FR-28). + // pastes plain text and Paste as Markdown converts. CommandGroup(after: .pasteboard) { Button("Paste and Match Style") { NSApp.sendAction(#selector(NSTextView.pasteAsPlainText(_:)), to: nil, from: nil) diff --git a/Sources/MacDownKit/Document/DocumentController.swift b/Sources/MacDownKit/Document/DocumentController.swift index 392256f..dee8c39 100644 --- a/Sources/MacDownKit/Document/DocumentController.swift +++ b/Sources/MacDownKit/Document/DocumentController.swift @@ -8,7 +8,6 @@ // import AppKit -import CPegMarkdown import Observation import UniformTypeIdentifiers @@ -79,9 +78,7 @@ public final class DocumentController: NSObject { @ObservationIgnored private var editorTextEnd: CGFloat = 0 /// What `editorAnchors` were computed for, to skip recomputing them. @ObservationIgnored private var editorLayoutSyncScheduled = false - @ObservationIgnored private var editorAnchorsKey: (text: String, width: CGFloat, - frontMatter: Bool, fencedCode: Bool, - lines: [Int])? + @ObservationIgnored private var editorAnchorsKey: (text: String, width: CGFloat, lines: [Int])? @ObservationIgnored private(set) var previewMetrics = PreviewMetrics() /// The pane the user scrolled last; the other one follows it. @ObservationIgnored private var scrollLeader = ScrollLeader.editor @@ -93,7 +90,7 @@ public final class DocumentController: NSObject { /// Preferences that change the editor's setup (see `setupEditor`). private static let editorPreferencesToObserve: Set = [ - .editorBaseFontInfo, .editorHorizontalInset, .markdownEngine, + .editorBaseFontInfo, .editorHorizontalInset, .editorVerticalInset, .editorWidthLimited, .editorMaximumWidth, .editorLineSpacing, .editorOnRight, .editorStyleName, .editorShowWordCount, .editorScrollsPastEnd, .editorConvertsPastedFormatting, @@ -144,7 +141,6 @@ public final class DocumentController: NSObject { isSetUp = true setupEditor(nil) parseAndRenderNow() - highlighter.parseAndHighlightNow() } /// Replaces the model, e.g. after "Revert to Saved". @@ -158,7 +154,6 @@ public final class DocumentController: NSObject { savedText = newDocument.text if !keepsDraft && editor.string != newDocument.text { editor.string = newDocument.text - highlighter.parseAndHighlightNow() parseAndRenderNow() } updateUnsavedState() @@ -286,7 +281,6 @@ public final class DocumentController: NSObject { set { editor.string = newValue draftDidChange() - highlighter.parseAndHighlightNow() parseAndRender() } } @@ -522,7 +516,6 @@ public final class DocumentController: NSObject { length: 0)) editorScrollView.contentView.scroll(to: origin) editorScrollView.reflectScrolledClipView(editorScrollView.contentView) - highlighter.parseAndHighlightNow() parseAndRenderNow() } // Saving automatically, the document now matches the file. @@ -631,15 +624,14 @@ public final class DocumentController: NSObject { render() } - /// With the swift-markdown engine, the editor is highlighted from the - /// renderer's model of the same text (one parse for both, FR-1), and - /// learns where its code blocks are, for pasting (FR-5). + /// The editor is highlighted from the renderer's model of the same text + /// (one parse for both), and learns where its code blocks are, for + /// pasting. private func highlightFromModel() { if let model = renderer.model { editor.documentBlocks = (model.source, model.blocks) } - guard highlighter.usesExternalElements, let model = renderer.model, - model.source == editor.string + guard let model = renderer.model, model.source == editor.string else { return } highlighter.update(model.highlights) } @@ -749,7 +741,7 @@ public final class DocumentController: NSObject { scrollLeader = .editor if needsHtml { parseAndRender() - } else if highlighter.usesExternalElements { + } else { parseForHighlighting() } } @@ -778,7 +770,7 @@ public final class DocumentController: NSObject { || settings.parse != renderer.lastParseSettings { if needsHtml || renderer.lastParseSettings != nil { parseAndRender() - } else if highlighter.usesExternalElements { + } else { parseForHighlighting() } } else if settings.page != renderer.lastPageSettings { @@ -801,8 +793,6 @@ public final class DocumentController: NSObject { editorAnchorsKey = nil // Fonts and insets move the text. highlighter.deactivate() - highlighter.extensions = Int32(pmh_EXT_NOTES.rawValue) // Footnotes are standard. - highlighter.usesExternalElements = preferences.markdownEngine == .cmarkGfm if changedKey == nil || [.editorHorizontalInset, .editorVerticalInset, .editorWidthLimited, .editorMaximumWidth] @@ -987,36 +977,22 @@ public final class DocumentController: NSObject { guard let layoutManager = editor.layoutManager, let container = editor.textContainer else { return } - // The preview's source lines, when the new engine marks them. - let lines = previewMetrics.anchors.compactMap { anchor -> Int? in - if case .line(let line) = anchor.kind { line } else { nil } - } - let key = (text: editor.string, width: container.size.width, - frontMatter: true, fencedCode: true, lines: lines) + // The preview's source lines. + let lines = previewMetrics.anchors.map(\.line) + let key = (text: editor.string, width: container.size.width, lines: lines) if let old = editorAnchorsKey, old.text == key.text, old.width == key.width, old.lines == key.lines { return } editorAnchorsKey = key let origin = editor.textContainerOrigin.y layoutManager.ensureLayout(for: container) - if !lines.isEmpty { - // The top of each of those lines in the editor. - let index = LineIndex(key.text) - let length = (key.text as NSString).length - editorAnchors = Set(lines).sorted().compactMap { line in - guard let offset = index.utf16Offset(line: line, column: 1) else { return nil } - let glyph = layoutManager.glyphIndexForCharacter(at: min(offset, max(0, length - 1))) - let rect = layoutManager.lineFragmentRect(forGlyphAt: glyph, effectiveRange: nil) - return ScrollAnchor(.line(line), origin + rect.minY) - } - } else { - let sourceAnchors = ScrollAnchors.scan(key.text, skipsFrontMatter: key.frontMatter, - fencedCode: key.fencedCode) - editorAnchors = sourceAnchors.map { anchor in - let glyphRange = layoutManager.glyphRange(forCharacterRange: anchor.range, - actualCharacterRange: nil) - let rect = layoutManager.boundingRect(forGlyphRange: glyphRange, in: container) - return ScrollAnchor(anchor.kind, origin + rect.midY) - } + // The top of each of those lines in the editor. + let index = LineIndex(key.text) + let length = (key.text as NSString).length + editorAnchors = Set(lines).sorted().compactMap { line in + guard let offset = index.utf16Offset(line: line, column: 1) else { return nil } + let glyph = layoutManager.glyphIndexForCharacter(at: min(offset, max(0, length - 1))) + let rect = layoutManager.lineFragmentRect(forGlyphAt: glyph, effectiveRange: nil) + return ScrollAnchor(line: line, origin + rect.minY) } editorTextEnd = origin + layoutManager.usedRect(for: container).maxY } diff --git a/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Renderer.swift b/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Renderer.swift index 54babde..6de2865 100644 --- a/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Renderer.swift +++ b/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Renderer.swift @@ -11,8 +11,8 @@ extension HTMLToMarkdown { struct Renderer { let options: Options - /// The blocks separated by one blank line (FR-21); a lone paragraph - /// has no newline, to be inserted inline (FR-9). + /// The blocks separated by one blank line; a lone paragraph + /// has no newline, to be inserted inline. func render(_ blocks: [Block]) -> Result { let rendered = renderedBlocks(blocks) let markdown = rendered.map(\.text).joined(separator: "\n\n") @@ -59,7 +59,6 @@ extension HTMLToMarkdown { case .list(let list): return render(list, alternate: alternate) case .quote(let blocks): - // FR-17 return renderedBlocks(blocks).map(\.text).joined(separator: "\n\n") .split(separator: "\n", omittingEmptySubsequences: false) .map { $0.isEmpty ? ">" : "> " + $0 } @@ -74,7 +73,7 @@ extension HTMLToMarkdown { // MARK: - Lists - /// A list with the writer's marker (FR-16). Items are separated by + /// A list with the writer's marker. Items are separated by /// blank lines when any holds more than one block; an item's lines /// after the first are indented by the indent setting, or to the /// content column when the marker is wider. @@ -119,7 +118,7 @@ extension HTMLToMarkdown { // MARK: - Inline content - /// Emphasis, outermost first (FR-11). + /// Emphasis, outermost first. enum Emphasis: CaseIterable { case strike, bold, italic @@ -183,7 +182,7 @@ extension HTMLToMarkdown { return "[\(text)](\(destination(link.url, title: link.title)))" } - /// `![alt](src "title")` (FR-15). + /// `![alt](src "title")`. static func image(_ image: Image) -> String { "![\(escape(image.alt, atLineStart: false))](\(destination(image.source, title: image.title)))" } @@ -283,7 +282,7 @@ extension HTMLToMarkdown { return output + renderCode(plain, lineStart: &lineStart) } - /// Monospace runs as code spans, the rest as escaped text (FR-12). + /// Monospace runs as code spans, the rest as escaped text. private func renderCode(_ inlines: [Inline], lineStart: inout Bool) -> String { var output = "" var code = "" @@ -382,7 +381,7 @@ extension HTMLToMarkdown { private static let entity = try! NSRegularExpression(pattern: #"^&(?:#[0-9xX]|[A-Za-z][A-Za-z0-9]*;)"#) /// Text with the characters escaped that would otherwise be read as - /// Markdown, and only those (FR-20). `atLineStart` also escapes what + /// Markdown, and only those. `atLineStart` also escapes what /// would start a block: a heading, quote, list item or rule. static func escape(_ text: String, atLineStart: Bool, inTable: Bool = false) -> String { let characters = Array(text) diff --git a/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Tables.swift b/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Tables.swift index d6e0732..d3ef7ae 100644 --- a/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Tables.swift +++ b/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Tables.swift @@ -2,7 +2,7 @@ // HTMLToMarkdown+Tables.swift // MacDownKit // -// Tables (FR-18): a GFM pipe table when every cell is one line of inline +// Tables: a GFM pipe table when every cell is one line of inline // content and none spans rows or columns; otherwise the table stays HTML, // with its cells' formatting written as HTML tags. // diff --git a/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Walker.swift b/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Walker.swift index b14e2fb..79899aa 100644 --- a/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Walker.swift +++ b/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Walker.swift @@ -68,8 +68,7 @@ extension HTMLToMarkdown { "table", "tbody", "td", "tfoot", "th", "thead", "tr", "ul", ] - /// Elements that aren't content, dropped with everything in them - /// (FR-19). + /// Elements that aren't content, dropped with everything in them. static let droppedElements: Set = [ "audio", "button", "canvas", "embed", "head", "iframe", "link", "meta", "noscript", "object", "script", "select", "style", "svg", "template", "title", "video", @@ -81,7 +80,7 @@ extension HTMLToMarkdown { let tag = element.localName?.lowercased() ?? "" if Self.droppedElements.contains(tag) { return nil } // A footnote's link back to its reference (↩), as MacDown's - // preview writes it, means nothing without the footnote (FR-26). + // preview writes it, means nothing without the footnote. if tag == "a", element.attribute(forName: "rev")?.stringValue == "footnote" { return nil } // Material icons are ligatures: their text is the icon's name. if let classes = element.attribute(forName: "class")?.stringValue, @@ -174,7 +173,7 @@ extension HTMLToMarkdown { return blocks(in: element, style: style) } - /// A `ul` or `ol` as a list (FR-16). Empty items are dropped, and an + /// A `ul` or `ol` as a list. Empty items are dropped, and an /// item holding only lists (Tidy's repair of a list directly inside /// a list, as Google Docs writes it) joins the previous item. func list(_ element: XMLElement, style: TextStyle) -> [Block] { @@ -243,7 +242,7 @@ extension HTMLToMarkdown { } /// An image's address: its `src`, or for lazily loaded images, the - /// first in its `srcset` or its `data-src` (FR-25). + /// first in its `srcset` or its `data-src`. static func imageSource(_ image: XMLElement) -> String? { if let source = image.attribute(forName: "src")?.stringValue, !source.isEmpty { return source } if let set = image.attribute(forName: "srcset")?.stringValue, @@ -253,7 +252,7 @@ extension HTMLToMarkdown { return image.attribute(forName: "data-src")?.stringValue } - /// A `pre` element's text, verbatim, as a code block (FR-13). + /// A `pre` element's text, verbatim, as a code block. static func codeBlock(_ pre: XMLElement) -> Block? { var text = "" func visit(_ node: XMLNode) { @@ -323,7 +322,7 @@ extension HTMLToMarkdown { let tag = element.localName?.lowercased() ?? "" if tag == "br" { return [.lineBreak] } if tag == "img" { - // Kept as an address, never fetched (FR-34). + // Kept as an address, never fetched. guard let source = Self.imageSource(element), let link = link(source, title: element.attribute(forName: "title")?.stringValue) else { return [] } @@ -339,8 +338,7 @@ extension HTMLToMarkdown { } /// A link to `href`, resolved against the base URL; nil for scripts - /// and links within the copied page, which keep only their text - /// (FR-14). + /// and links within the copied page, which keep only their text. func link(_ href: String, title: String?) -> Link? { let href = href.trimmingCharacters(in: .whitespacesAndNewlines) guard !href.isEmpty, !href.hasPrefix("#"), !href.lowercased().hasPrefix("javascript:") diff --git a/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Word.swift b/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Word.swift index 5239aa2..8f7c41f 100644 --- a/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Word.swift +++ b/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown+Word.swift @@ -2,7 +2,7 @@ // HTMLToMarkdown+Word.swift // MacDownKit // -// Word's lists (FR-23): Word writes each list item as a paragraph styled +// Word's lists: Word writes each list item as a paragraph styled // `mso-list: lN levelM`, its bullet or number as text in a span styled // `mso-list: Ignore`. Consecutive items become nested lists again. // diff --git a/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown.swift b/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown.swift index 933e0b3..cd8b38f 100644 --- a/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown.swift +++ b/Sources/MacDownKit/Document/HTMLToMarkdown/HTMLToMarkdown.swift @@ -31,10 +31,10 @@ public struct HTMLToMarkdown: Sendable { public struct Result: Sendable, Equatable { public var markdown: String /// A single paragraph, inserted inline without paragraph breaks - /// around it (FR-9). + /// around it. public var isInline: Bool /// The HTML looks like code from a code editor or terminal, to be - /// pasted as plain text instead (FR-6). + /// pasted as plain text instead. public var isCode = false } @@ -53,8 +53,8 @@ public struct HTMLToMarkdown: Sendable { return result.markdown.isEmpty ? nil : result } - /// Whether blocks look like code copied from a code editor or terminal - /// (FR-6): all their visible text is monospace (or in code blocks), with + /// Whether blocks look like code copied from a code editor or terminal: + /// all their visible text is monospace (or in code blocks), with /// no links, images, headings, lists, quotes or tables. Bold or colored /// keywords, as some editors' themes have, don't count. static func isCode(_ blocks: [Block]) -> Bool { diff --git a/Sources/MacDownKit/Document/MarkdownParser.swift b/Sources/MacDownKit/Document/MarkdownParser.swift deleted file mode 100644 index ac07ae3..0000000 --- a/Sources/MacDownKit/Document/MarkdownParser.swift +++ /dev/null @@ -1,170 +0,0 @@ -// -// MarkdownParser.swift -// MacDown -// -// The hoedown bridge, ported from the C-level parts of MPRenderer.m. -// Everything here is free of actor state so it can run in the background. -// - -import Foundation -import CHoedown - -/// Settings that affect the Markdown → HTML body conversion. -public struct ParseSettings: Sendable, Equatable { - public var extensionFlags: UInt32 = 0 - public var rendererFlags: UInt32 = 0 - public var smartyPants = false - public var rendersTOC = false - public var detectsFrontMatter = false - /// Which parser renders: hoedown, or cmark-gfm through the document - /// model (the hidden `markdownEngine` setting). - public var engine = MarkdownEngine.cmarkGfm - - public init(extensionFlags: UInt32 = 0, rendererFlags: UInt32 = 0, - smartyPants: Bool = false, rendersTOC: Bool = false, - detectsFrontMatter: Bool = false, engine: MarkdownEngine = .cmarkGfm) { - self.extensionFlags = extensionFlags - self.rendererFlags = rendererFlags - self.smartyPants = smartyPants - self.rendersTOC = rendersTOC - self.detectsFrontMatter = detectsFrontMatter - self.engine = engine - } -} - -public struct ParseResult: Sendable, Equatable { - /// The rendered HTML body. - public var body: String - /// Prism languages used in code blocks, dependencies first. - public var languages: [String] -} - -public enum MarkdownParser { - static let nestingLevel = Int(Int32.max) - static let tocLevel: Int32 = 6 // h1 to h6. - - public static func parse(_ markdown: String, settings: ParseSettings) -> ParseResult { - var markdown = markdown - var frontMatterHTML: String? - if settings.detectsFrontMatter { - let (object, offset) = markdown.frontMatter() - if offset > 0 { - markdown = markdown.ns.substring(from: offset) - } - frontMatterHTML = object?.htmlTable - } - - let collector = LanguageCollector() - let unmanaged = Unmanaged.passRetained(collector) - defer { unmanaged.release() } - - let htmlRenderer = createHTMLRenderer(flags: settings.rendererFlags, - owner: unmanaged.toOpaque()) - defer { freeHTMLRenderer(htmlRenderer) } - var tocRenderer: UnsafeMutablePointer? - if settings.rendersTOC { - tocRenderer = hoedown_html_toc_renderer_new(tocLevel) - tocRenderer?.pointee.header = hoedown_patch_render_toc_header - } - defer { if let tocRenderer { hoedown_html_renderer_free(tocRenderer) } } - - var body = render(markdown, renderer: htmlRenderer, - extensions: settings.extensionFlags, - smartyPants: settings.smartyPants) - if let tocRenderer { - let toc = render(markdown, renderer: tocRenderer, - extensions: settings.extensionFlags, - smartyPants: false) - body = tocRegex.stringByReplacingMatches( - in: body, range: NSRange(location: 0, length: body.ns.length), - withTemplate: NSRegularExpression.escapedTemplate(for: toc)) - } - if let frontMatterHTML { - body = "\(frontMatterHTML)\n\(body)" - } - return ParseResult(body: body, languages: collector.languages) - } - - private static let tocRegex = try! NSRegularExpression( - pattern: "\\s*\\[TOC\\]\\s*

    ", options: .caseInsensitive) - - private static func render(_ text: String, - renderer: UnsafeMutablePointer, - extensions: UInt32, smartyPants: Bool) -> String { - let document = hoedown_document_new( - renderer, hoedown_extensions(rawValue: extensions), nestingLevel) - defer { hoedown_document_free(document) } - - var ob = hoedown_buffer_new(64) - var utf8 = Array(text.utf8) - utf8.withUnsafeMutableBufferPointer { buffer in - hoedown_document_render(document, ob, buffer.baseAddress, buffer.count) - } - if smartyPants { - let ib = ob - ob = hoedown_buffer_new(64) - hoedown_html_smartypants(ob, ib?.pointee.data, ib?.pointee.size ?? 0) - hoedown_buffer_free(ib) - } - defer { hoedown_buffer_free(ob) } - guard let ob, let data = ob.pointee.data else { return "" } - let bytes = UnsafeBufferPointer(start: data, count: ob.pointee.size) - return String(decoding: bytes, as: UTF8.self) - } - - private static func createHTMLRenderer( - flags: UInt32, owner: UnsafeMutableRawPointer - ) -> UnsafeMutablePointer { - let renderer = hoedown_html_renderer_new( - hoedown_html_flags(rawValue: flags), tocLevel)! - renderer.pointee.blockcode = hoedown_patch_render_blockcode - renderer.pointee.listitem = hoedown_patch_render_listitem - - let extra = UnsafeMutablePointer - .allocate(capacity: 1) - extra.initialize(to: hoedown_html_renderer_state_extra( - language_addition: languageAddition, owner: owner)) - let state = renderer.pointee.opaque - .assumingMemoryBound(to: hoedown_html_renderer_state.self) - state.pointee.opaque = UnsafeMutableRawPointer(extra) - return renderer - } - - private static func freeHTMLRenderer(_ renderer: UnsafeMutablePointer) { - let state = renderer.pointee.opaque - .assumingMemoryBound(to: hoedown_html_renderer_state.self) - if let extra = state.pointee.opaque { - extra.assumingMemoryBound(to: hoedown_html_renderer_state_extra.self) - .deallocate() - state.pointee.opaque = nil - } - hoedown_html_renderer_free(renderer) - } -} - -/// Called by the patched block code renderer for every fenced code block -/// language. Maps aliases and records the Prism scripts required. -private let languageAddition: @convention(c) ( - UnsafePointer?, UnsafeMutableRawPointer? -) -> UnsafeMutablePointer? = { language, owner in - guard let language, let owner, let data = language.pointee.data else { - return nil - } - let collector = Unmanaged.fromOpaque(owner) - .takeUnretainedValue() - var lang = String(decoding: UnsafeBufferPointer(start: data, - count: language.pointee.size), - as: UTF8.self) - - // Try to identify alias and point it to the "real" language name. - var mapped: UnsafeMutablePointer? - if let real = PrismLanguages.aliases[lang] { - lang = real - let bytes = Array(real.utf8) - mapped = hoedown_buffer_new(64) - hoedown_buffer_put(mapped, bytes, bytes.count) - } - // Walk dependencies to include all required scripts. - collector.add(lang) - return mapped -} diff --git a/Sources/MacDownKit/Document/Model/CMarkTree.swift b/Sources/MacDownKit/Document/Model/CMarkTree.swift index da883e0..d0cd29d 100644 --- a/Sources/MacDownKit/Document/Model/CMarkTree.swift +++ b/Sources/MacDownKit/Document/Model/CMarkTree.swift @@ -2,7 +2,7 @@ // CMarkTree.swift // MacDownKit // -// One cmark-gfm parse (Decision 10): the C tree, walked in place by the +// One cmark-gfm parse: the C tree, walked in place by the // model, the highlighter and the renderer inside the parse task. Neither // the tree nor its nodes are Sendable; only what's built from them leaves. // diff --git a/Sources/MacDownKit/Document/Model/ExtendedSyntax.swift b/Sources/MacDownKit/Document/Model/ExtendedSyntax.swift index 3fcb0f3..4d6f39b 100644 --- a/Sources/MacDownKit/Document/Model/ExtendedSyntax.swift +++ b/Sources/MacDownKit/Document/Model/ExtendedSyntax.swift @@ -2,9 +2,9 @@ // ExtendedSyntax.swift // MacDownKit // -// Opt-in syntax swift-markdown doesn't parse (finding F4), found in plain -// text the same way for the editor highlighting and the preview (FR-19, -// FR-19a), with hoedown's rules. +// Opt-in syntax cmark-gfm doesn't parse (`==highlight==`, `x^2`), found in +// plain text the same way for the editor highlighting and the preview, +// with hoedown's rules. // import Foundation diff --git a/Sources/MacDownKit/Document/Model/HTMLRenderer.swift b/Sources/MacDownKit/Document/Model/HTMLRenderer.swift index 881b0a3..e091ba3 100644 --- a/Sources/MacDownKit/Document/Model/HTMLRenderer.swift +++ b/Sources/MacDownKit/Document/Model/HTMLRenderer.swift @@ -2,8 +2,8 @@ // HTMLRenderer.swift // MacDownKit // -// The preview's HTML body from the cmark-gfm tree (FR-7 to FR-20, TR-4, -// TR-5), in the markup hoedown and MacDown's patches produced, since the +// The preview's HTML body from the cmark-gfm tree, in the markup hoedown +// and MacDown's C patches produced, since the // bundled styles and page scripts rely on it: header ids `toc_N`, Prism // code blocks, task-list items, hoedown's footnotes. Runs inside the parse // task; only the HTML string leaves it. @@ -21,13 +21,13 @@ struct HTMLRenderer { /// Every line break in a paragraph is a
    . var hardWrap = false /// Protected math, in source order, to put back in place of its - /// filler (FR-14). + /// filler. var math: [MathSpan] = [] - /// `==mark==` and `x^2` in plain text (FR-19, FR-19a). + /// `==mark==` and `x^2` in plain text. var highlight = false var superscript = false /// Blocks name their first source line, for scroll sync (preview - /// only; FR-18). + /// only: exports leave it out). var sourceLines = false } @@ -215,7 +215,7 @@ struct HTMLRenderer { while output.hasSuffix("\n") { output.removeLast() } } - /// MacDown's Prism-compatible block code (hoedown_html_patch.c). + /// MacDown's Prism-compatible block code (as its hoedown patch wrote it). private mutating func codeBlock(_ node: CMarkNode) { newline() var language = (node.fenceInfo ?? "").split(whereSeparator: \.isWhitespace).first.map(String.init) ?? "" @@ -394,7 +394,7 @@ struct HTMLRenderer { pattern: "\\s*\\[TOC\\]\\s*

    ", options: .caseInsensitive) /// hoedown's TOC (with MacDown's "toc" class on the outer list) in place - /// of every `[TOC]` paragraph, as MarkdownParser did. + /// of every `[TOC]` paragraph. private mutating func insertTableOfContents() { guard output.contains("TOC]") else { return } var toc = "" diff --git a/Sources/MacDownKit/Document/Model/HighlightMapper.swift b/Sources/MacDownKit/Document/Model/HighlightMapper.swift index 50ef2cf..c42da16 100644 --- a/Sources/MacDownKit/Document/Model/HighlightMapper.swift +++ b/Sources/MacDownKit/Document/Model/HighlightMapper.swift @@ -2,12 +2,12 @@ // HighlightMapper.swift // MacDownKit // -// Editor highlighting from the cmark-gfm tree (FR-21, FR-22): the spans +// Editor highlighting from the cmark-gfm tree: the spans // PEG Markdown Highlight produced, keyed by the same element types, so the // bundled themes apply unchanged. Spans follow PEG's extents: headers cover // their line(s) and line break, emphasis, code, links and images include // their markup, fenced code is CODE and indented code VERBATIM, and a block -// quote colors only its `>` markers. Footnotes are NOTE (FR-27). +// quote colors only its `>` markers. Footnotes are NOTE. // // What the tree doesn't keep comes from the source: reference definitions // (cmark consumes them) and entities (cmark decodes them). The same walk diff --git a/Sources/MacDownKit/Document/Model/LineIndex.swift b/Sources/MacDownKit/Document/Model/LineIndex.swift index e500f39..e540d01 100644 --- a/Sources/MacDownKit/Document/Model/LineIndex.swift +++ b/Sources/MacDownKit/Document/Model/LineIndex.swift @@ -3,8 +3,8 @@ // MacDownKit // // Converts swift-markdown source positions (1-based line, and 1-based column -// in UTF-8 bytes) to the UTF-16 offsets NSString and NSTextView use -// (TR-3). Lines end at "\n", "\r\n" or a lone "\r", as in cmark. +// in UTF-8 bytes) to the UTF-16 offsets NSString and NSTextView use. +// Lines end at "\n", "\r\n" or a lone "\r", as in cmark. // import Foundation diff --git a/Sources/MacDownKit/Document/Model/MarkdownDocumentModel.swift b/Sources/MacDownKit/Document/Model/MarkdownDocumentModel.swift index 5310e22..87fbbd3 100644 --- a/Sources/MacDownKit/Document/Model/MarkdownDocumentModel.swift +++ b/Sources/MacDownKit/Document/Model/MarkdownDocumentModel.swift @@ -2,14 +2,12 @@ // MarkdownDocumentModel.swift // MacDownKit // -// One parse of a document with swift-markdown, shared by the preview, the -// editor highlighting and scroll sync (FR-1 to FR-3). The cmark-gfm tree -// (Decision 10) isn't Sendable, so the model is built where the parse runs +// One parse of a document with cmark-gfm, shared by the preview, the +// editor highlighting and scroll sync. The cmark-gfm tree isn't Sendable, so the model is built where the parse runs // (a detached task) and keeps only what's produced from the tree. Only this -// folder uses the cmark-gfm API (TR-2). +// folder uses the cmark-gfm API. // -import CHoedown import Foundation public struct MarkdownDocumentModel: Sendable { @@ -43,16 +41,16 @@ public struct MarkdownDocumentModel: Sendable { } public init(_ settings: ParseSettings) { - math = settings.extensionFlags & HOEDOWN_EXT_MATH.rawValue != 0 - inlineDollar = math && settings.extensionFlags & HOEDOWN_EXT_MATH_EXPLICIT.rawValue != 0 - smartPunctuation = settings.smartyPants - highlight = settings.extensionFlags & HOEDOWN_EXT_HIGHLIGHT.rawValue != 0 - superscript = settings.extensionFlags & HOEDOWN_EXT_SUPERSCRIPT.rawValue != 0 - autolink = settings.extensionFlags & HOEDOWN_EXT_AUTOLINK.rawValue != 0 - lineNumbers = settings.rendererFlags & UInt32(HOEDOWN_HTML_BLOCKCODE_LINE_NUMBERS) != 0 - blockCodeInformation = settings.rendererFlags & UInt32(HOEDOWN_HTML_BLOCKCODE_INFORMATION) != 0 + math = settings.math + inlineDollar = settings.math && settings.inlineDollar + smartPunctuation = settings.smartPunctuation + highlight = settings.highlight + superscript = settings.superscript + autolink = settings.autolink + lineNumbers = settings.lineNumbers + blockCodeInformation = settings.blockCodeInformation rendersTOC = settings.rendersTOC - hardWrap = settings.rendererFlags & HOEDOWN_HTML_HARD_WRAP.rawValue != 0 + hardWrap = settings.hardWrap } } @@ -78,7 +76,7 @@ public struct MarkdownDocumentModel: Sendable { public let math: [NSRange] /// Blocks in document order (parents before their children). public let blocks: [Block] - /// Editor highlighting, by PEG element type (`ThemeStyle.elementNames`). + /// Editor highlighting, by `HighlightElement` (`ThemeStyle.elementNames`). let highlights: HighlightElements /// The preview's HTML body, and the Prism languages its code uses. public let body: String @@ -109,7 +107,7 @@ public struct MarkdownDocumentModel: Sendable { highlight: options.highlight, superscript: options.superscript, sourceLines: options.sourceLines)) languages = rendered.languages - // Front matter is a table before the body (FR-15), as with hoedown. + // Front matter is a table before the body, as with hoedown. if let table = protected.frontMatter?.object.htmlTable { body = table + "\n" + rendered.html } else { diff --git a/Sources/MacDownKit/Document/Model/ProtectedSource.swift b/Sources/MacDownKit/Document/Model/ProtectedSource.swift index 94400fb..a357bce 100644 --- a/Sources/MacDownKit/Document/Model/ProtectedSource.swift +++ b/Sources/MacDownKit/Document/Model/ProtectedSource.swift @@ -3,7 +3,7 @@ // MacDownKit // // Hides math and front matter from the Markdown parser without moving any -// source position (FR-4, FR-5). Each protected span is replaced by filler of +// source position. Each protected span is replaced by filler of // the same UTF-8 length, keeping its line breaks. Math becomes characters // no document uses (Private Use Area, padded with C0/C1 controls), which the // parser takes as ordinary text and the renderer finds again to put the diff --git a/Sources/MacDownKit/Document/PrismLanguages.swift b/Sources/MacDownKit/Document/PrismLanguages.swift index 1db4e10..e7785f7 100644 --- a/Sources/MacDownKit/Document/PrismLanguages.swift +++ b/Sources/MacDownKit/Document/PrismLanguages.swift @@ -2,7 +2,7 @@ // PrismLanguages.swift // MacDownKit // -// Code block languages for Prism, shared by both Markdown engines (FR-10): +// Code block languages for Prism, shared by both Markdown engines: // aliases map to Prism's names (`js` → `javascript`), and each language // brings the scripts it depends on. // diff --git a/Sources/MacDownKit/Document/Renderer.swift b/Sources/MacDownKit/Document/Renderer.swift index ecc0ec3..c10344a 100644 --- a/Sources/MacDownKit/Document/Renderer.swift +++ b/Sources/MacDownKit/Document/Renderer.swift @@ -7,7 +7,39 @@ // import Foundation -import CHoedown + +/// Settings that affect the Markdown → HTML body conversion. Standard +/// Markdown (CommonMark and GFM: tables, task lists, strikethrough, +/// footnotes, front matter) is always on; these are the opt-in extras. +public struct ParseSettings: Sendable, Equatable { + /// Bare URLs and email addresses as links. + public var autolink = false + /// `==text==` as . + public var highlight = false + /// `x^2` and `x^(y z)` as . + public var superscript = false + /// TeX math for MathJax, and with `inlineDollar`, `$…$` inline. + public var math = false + public var inlineDollar = false + /// Curly quotes, dashes and ellipses. + public var smartPunctuation = false + /// Code blocks: line numbers, and the `lang:info` accessory. + public var lineNumbers = false + public var blockCodeInformation = false + /// Every newline in a paragraph is a line break. + public var hardWrap = false + /// A paragraph of just `[TOC]` becomes a table of contents. + public var rendersTOC = false + + public init() {} +} + +public struct ParseResult: Sendable, Equatable { + /// The rendered HTML body. + public var body: String + /// Prism languages used in code blocks, dependencies first. + public var languages: [String] +} /// Settings that affect how the HTML page is assembled around the body. public struct PageSettings: Sendable, Equatable { @@ -43,29 +75,20 @@ public struct RenderSettings: Sendable, Equatable { @MainActor extension Preferences { - /// Standard Markdown (tables, fenced code, footnotes, strikethrough and - /// intra-word emphasis) is always on; extended syntax is opt-in. Quote - /// (`"…"` as ``) is dropped in favor of smart punctuation. - public var extensionFlags: UInt32 { - var flags: UInt32 = HOEDOWN_EXT_TABLES.rawValue | HOEDOWN_EXT_FENCED_CODE.rawValue - | HOEDOWN_EXT_FOOTNOTES.rawValue | HOEDOWN_EXT_STRIKETHROUGH.rawValue - if extensionAutolink { flags |= HOEDOWN_EXT_AUTOLINK.rawValue } - if extensionHighlight { flags |= HOEDOWN_EXT_HIGHLIGHT.rawValue } - if extensionSuperscript { flags |= HOEDOWN_EXT_SUPERSCRIPT.rawValue } - if htmlMathJax { flags |= HOEDOWN_EXT_MATH.rawValue } - if htmlMathJaxInlineDollar { flags |= HOEDOWN_EXT_MATH_EXPLICIT.rawValue } - return flags - } - - /// Task lists are standard (GFM) and always on. - public var rendererFlags: UInt32 { - var flags = UInt32(HOEDOWN_HTML_USE_TASK_LIST) - if htmlLineNumbers { flags |= UInt32(HOEDOWN_HTML_BLOCKCODE_LINE_NUMBERS) } - if htmlHardWrap { flags |= HOEDOWN_HTML_HARD_WRAP.rawValue } - if codeBlockAccessory == .custom { - flags |= UInt32(HOEDOWN_HTML_BLOCKCODE_INFORMATION) - } - return flags + /// The opt-in Markdown settings (standard Markdown is always on). + public var parseSettings: ParseSettings { + var settings = ParseSettings() + settings.autolink = extensionAutolink + settings.highlight = extensionHighlight + settings.superscript = extensionSuperscript + settings.math = htmlMathJax + settings.inlineDollar = htmlMathJaxInlineDollar + settings.smartPunctuation = extensionSmartyPants + settings.lineNumbers = htmlLineNumbers + settings.blockCodeInformation = codeBlockAccessory == .custom + settings.hardWrap = htmlHardWrap + settings.rendersTOC = htmlRendersTOC + return settings } public var renderSettings: RenderSettings { @@ -82,14 +105,7 @@ extension Preferences { page.mathJax = htmlMathJax page.templateName = htmlTemplateName ?? "Default" page.baseFontSize = htmlBaseFontSize - return RenderSettings( - parse: ParseSettings(extensionFlags: extensionFlags, - rendererFlags: rendererFlags, - smartyPants: extensionSmartyPants, - rendersTOC: htmlRendersTOC, - detectsFrontMatter: true, - engine: markdownEngine), - page: page) + return RenderSettings(parse: parseSettings, page: page) } } @@ -280,7 +296,7 @@ public enum PageBuilder { linkTransform: linkTransform) } - /// HTML without the preview's `data-source-line` attributes (FR-18), + /// HTML without the preview's `data-source-line` attributes, /// for export and copying. public static func withoutSourceLines(_ html: String) -> String { guard html.contains(" data-source-line=") else { return html } @@ -334,7 +350,8 @@ public enum PageBuilder { @MainActor public final class Renderer { public private(set) var result = ParseResult(body: "", languages: []) - /// The swift-markdown model of the same text, when that engine is on. + /// The document model the result was rendered from, which the editor + /// highlights from too; nil before the first parse. public private(set) var model: MarkdownDocumentModel? public private(set) var lastParseSettings: ParseSettings? public private(set) var lastPageSettings: PageSettings? @@ -378,10 +395,7 @@ public final class Renderer { private nonisolated static func parse( _ markdown: String, _ settings: ParseSettings ) -> (ParseResult, MarkdownDocumentModel?) { - guard settings.engine == .cmarkGfm else { - return (MarkdownParser.parse(markdown, settings: settings), nil) - } - // One cmark-gfm parse for the preview and the editor (FR-20, NFR-3). + // One cmark-gfm parse for the preview and the editor. var options = MarkdownDocumentModel.Options(settings) options.sourceLines = true let model = MarkdownDocumentModel(markdown, options: options) diff --git a/Sources/MacDownKit/Document/ScrollSync.swift b/Sources/MacDownKit/Document/ScrollSync.swift index b651363..e31386b 100644 --- a/Sources/MacDownKit/Document/ScrollSync.swift +++ b/Sources/MacDownKit/Document/ScrollSync.swift @@ -4,196 +4,30 @@ // // Scroll synchronization between the editor and the preview. // -// Both panes report "anchors". With the cmark-gfm engine the preview marks -// every block with its source line, and anchors are those lines (at the -// block's top), paired by line number. With hoedown they are headers and -// stand-alone images, in document order, paired by index, so both sides -// must apply the same rules (see `ScrollAnchors.scan` and -// `PreviewController.fetchMetrics`). -// Pairs give a piecewise linear map between editor and preview content -// positions. Each pane is aligned at a focus line, which sits at the middle -// of the visible area, except within the first and last screen of the -// document where it tapers to the top and bottom edges, so both panes reach -// their top and bottom together. +// Both panes report "anchors": the preview marks every block with its +// source line (`data-source-line`), and anchors are those lines (at the +// block's top) in each pane, paired by line number. Pairs give a piecewise +// linear map between editor and preview content positions. Each pane is +// aligned at a focus line, which sits at the middle of the visible area, +// except within the first and last screen of the document where it tapers +// to the top and bottom edges, so both panes reach their top and bottom +// together. // import Foundation -public enum ScrollAnchorKind: Sendable, Equatable { - case header - case image - /// A 1-based source line (the new engine's `data-source-line`). - case line(Int) -} - public struct ScrollAnchor: Sendable, Equatable { - public var kind: ScrollAnchorKind - /// Vertical center of the anchor, in content coordinates. + /// A 1-based source line. + public var line: Int + /// Where the line's block starts, in content coordinates. public var position: CGFloat - public init(_ kind: ScrollAnchorKind, _ position: CGFloat) { - self.kind = kind + public init(line: Int, _ position: CGFloat) { + self.line = line self.position = position } } -/// Finds anchors in Markdown source, mirroring how hoedown renders them. -/// -/// Headers are ATX headers (`#` in the first column) and setext headers -/// (`===` or `---` under a paragraph line). Images count only when they make -/// up a whole top-level paragraph, one anchor per image; the preview applies -/// the same rule to `

    ` elements that contain nothing but images. Fenced -/// code blocks, HTML comment blocks and front matter are skipped. -public enum ScrollAnchors { - public struct SourceAnchor: Sendable, Equatable { - public var kind: ScrollAnchorKind - /// Character range (UTF-16) whose center is the anchor. - public var range: NSRange - } - - private static let fenceRegex = try! NSRegularExpression( - pattern: "^( {0,3})(`{3,}|~{3,})") - private static let setextRegex = try! NSRegularExpression( - pattern: "^(=+|-+) *$") - private static let hruleRegex = try! NSRegularExpression( - pattern: "^ {0,3}([-*_])( *\\1){2,} *$") - private static let blockStartRegex = try! NSRegularExpression( - pattern: "^( {0,3}([-*+]|\\d+\\.)[ \\t]| {0,3}>| {4}|\\t| {0,3}\\|)") - private static let imageRegex = try! NSRegularExpression( - pattern: "!\\[[^\\]]*\\](?:\\([^)]*\\)|\\[[^\\]]*\\])") - private static let imageLineRegex = try! NSRegularExpression( - pattern: "^ {0,3}(?:!\\[[^\\]]*\\](?:\\([^)]*\\)|\\[[^\\]]*\\])[ \\t]*)+$") - - private static func matches(_ regex: NSRegularExpression, _ line: String) -> Bool { - regex.firstMatch(in: line, range: NSRange(location: 0, length: line.utf16.count)) - != nil - } - - /// A code fence line, as hoedown's `is_codefence` sees it: up to three - /// spaces, then three or more backticks or tildes. - private static func fenceMarker(_ line: String) - -> (indent: Int, character: Character, width: Int, rest: Substring)? { - guard let match = fenceRegex.firstMatch( - in: line, range: NSRange(location: 0, length: line.utf16.count)), - let indent = Range(match.range(at: 1), in: line), - let marker = Range(match.range(at: 2), in: line) - else { return nil } - return (line[indent].count, line[marker].first!, line[marker].count, - line[marker.upperBound...]) - } - - /// - Parameter fencedCode: Whether hoedown's fenced code extension is on. - public static func scan(_ markdown: String, skipsFrontMatter: Bool, - fencedCode: Bool = true) -> [SourceAnchor] { - var anchors: [SourceAnchor] = [] - var location = 0 - if skipsFrontMatter { - location = markdown.frontMatter().offset - } - let text = (markdown as NSString).substring(from: location) - - var fence: (indent: Int, character: Character, width: Int)? - var inComment = false - // Lines of the current paragraph, as (location, line). - var paragraph: [(Int, String)] = [] - // Whether the previous line can be the text of a setext header. - var previousIsParagraphText = false - - func flushParagraph() { - defer { paragraph.removeAll() } - guard !paragraph.isEmpty, - paragraph.allSatisfy({ matches(imageLineRegex, $0.1) }) - else { return } - for (lineLocation, line) in paragraph { - let ns = line as NSString - for match in imageRegex.matches( - in: line, range: NSRange(location: 0, length: ns.length)) { - anchors.append(SourceAnchor( - kind: .image, - range: NSRange(location: lineLocation + match.range.location, - length: match.range.length))) - } - } - } - - for line in text.components(separatedBy: "\n") { - let lineLocation = location - let length = (line as NSString).length - location += length + 1 - let trimmed = line.trimmingCharacters(in: .whitespaces) - - if let open = fence { - // Closed by the same fence (indent, character and width) - // followed by nothing but spaces (parse_fencedcode). - if let close = fenceMarker(line), close.indent == open.indent, - close.character == open.character, close.width == open.width, - close.rest.allSatisfy({ $0 == " " }) { - fence = nil - } - continue - } - if inComment { - if line.contains("-->") { inComment = false } - continue - } - // Fences only start blocks; they don't interrupt paragraphs. A - // line with the fence characters again (```` ``a`` ````) is a - // code span, not a fence (parse_codefence). - if fencedCode, paragraph.isEmpty, let open = fenceMarker(line), - !open.rest.drop(while: { $0 == " " || $0 == "\t" }) - .contains(String(repeating: open.character, count: 3)) { - previousIsParagraphText = false - fence = (open.indent, open.character, open.width) - continue - } - if trimmed.isEmpty { - flushParagraph() - previousIsParagraphText = false - continue - } - if paragraph.isEmpty && line.hasPrefix("") - previousIsParagraphText = false - continue - } - if line.hasPrefix("#") { - flushParagraph() - anchors.append(SourceAnchor( - kind: .header, range: NSRange(location: lineLocation, length: length))) - previousIsParagraphText = false - continue - } - if previousIsParagraphText && matches(setextRegex, line), - let last = paragraph.last { - // The paragraph's last line becomes the header text. - paragraph.removeLast() - flushParagraph() - anchors.append(SourceAnchor( - kind: .header, - range: NSRange(location: last.0, length: location - 1 - last.0))) - previousIsParagraphText = false - continue - } - if matches(hruleRegex, line) { - flushParagraph() - previousIsParagraphText = false - continue - } - if paragraph.isEmpty && matches(blockStartRegex, line) { - // Lists, quotes, code and tables: not top-level paragraphs. - // Following lines belong to the same block until a blank line. - paragraph.append((lineLocation, "\u{0}")) - previousIsParagraphText = false - continue - } - paragraph.append((lineLocation, line)) - previousIsParagraphText = paragraph.first?.1 != "\u{0}" - } - flushParagraph() - return anchors - } -} - /// Vertical geometry of one scrolling pane. public struct ScrollGeometry: Sendable, Equatable { public var contentHeight: CGFloat @@ -253,32 +87,17 @@ public struct ScrollMap: Sendable, Equatable { /// - previewEnd: Preview content height. public init(editor: [ScrollAnchor], preview: [ScrollAnchor], editorEnd: CGFloat, previewEnd: CGFloat) { - var editor = editor - var preview = preview - if case .line = preview.first?.kind { - // Pair by line number, in preview order. - var editorByLine: [Int: CGFloat] = [:] - for anchor in editor { - if case .line(let line) = anchor.kind, editorByLine[line] == nil { - editorByLine[line] = anchor.position - } - } - let paired = preview.compactMap { anchor -> (ScrollAnchor, ScrollAnchor)? in - guard case .line(let line) = anchor.kind, let y = editorByLine[line] else { return nil } - return (ScrollAnchor(anchor.kind, y), anchor) - } - editor = paired.map(\.0) - preview = paired.map(\.1) - } else if editor.map(\.kind) != preview.map(\.kind) { - // Something the rules didn't anticipate; headers are the most - // reliable, so try them alone before giving up on anchors. - editor = editor.filter { $0.kind == .header } - preview = preview.filter { $0.kind == .header } - if editor.count != preview.count { - editor = [] - preview = [] - } + // Pair by line number, in preview order. + var editorByLine: [Int: CGFloat] = [:] + for anchor in editor where editorByLine[anchor.line] == nil { + editorByLine[anchor.line] = anchor.position + } + let paired = preview.compactMap { anchor -> (ScrollAnchor, ScrollAnchor)? in + guard let y = editorByLine[anchor.line] else { return nil } + return (ScrollAnchor(line: anchor.line, y), anchor) } + let editor = paired.map(\.0) + let preview = paired.map(\.1) var pairs: [(editor: CGFloat, preview: CGFloat)] = [(0, 0)] for (e, p) in zip(editor, preview) { guard let last = pairs.last, e.position > last.editor, diff --git a/Sources/MacDownKit/Editor/EditorTextView+Paste.swift b/Sources/MacDownKit/Editor/EditorTextView+Paste.swift index c7de1e3..7c9ba31 100644 --- a/Sources/MacDownKit/Editor/EditorTextView+Paste.swift +++ b/Sources/MacDownKit/Editor/EditorTextView+Paste.swift @@ -10,8 +10,8 @@ import AppKit extension EditorTextView { // MARK: - Paste - /// Paste, Services and text dropped from other apps all read here - /// (FR-8): formatted text becomes Markdown and image data an image; + /// Paste, Services and text dropped from other apps all read here: + /// formatted text becomes Markdown and image data an image; /// anything else is read as usual. public override func readSelection(from pasteboard: NSPasteboard, type: NSPasteboard.PasteboardType) -> Bool { @@ -34,14 +34,14 @@ extension EditorTextView { .filter { !super.readablePasteboardTypes.contains($0) } } - /// Paste and Match Style: always the plain text (FR-4). + /// Paste and Match Style: always the plain text. public override func pasteAsPlainText(_ sender: Any?) { pastesPlainText = true defer { pastesPlainText = false } super.pasteAsPlainText(sender) } - /// Edit ▸ Paste as Markdown: converts even with the setting off (FR-28). + /// Edit ▸ Paste as Markdown: converts even with the setting off. @objc public func pasteAsMarkdown(_ sender: Any?) { if !pasteConverted(from: .general, convertsFormatting: true) { super.paste(sender) @@ -51,8 +51,8 @@ extension EditorTextView { /// Inserts the Markdown for `pasteboard`'s formatted text, or its /// image, in place of the selection, as one undoable change. False when /// there's nothing to convert, so the caller pastes as usual: plain - /// text, code (FR-6), a paste into a code block (FR-5), or formatted - /// text when not converting it (FR-27; images are pasted anyway, FR-34). + /// text, code, a paste into a code block, or formatted text when not + /// converting it (images are pasted either way). @discardableResult func pasteConverted(from pasteboard: NSPasteboard, convertsFormatting: Bool? = nil) -> Bool { let selection = selectedRange() @@ -82,7 +82,7 @@ extension EditorTextView { /// Inserts pasted Markdown as its own undo step (not merged with the /// typing before it), through the usual text-change path so the - /// document sees it like typing (FR-7). Blocks are set off from the + /// document sees it like typing. Blocks are set off from the /// text around them by blank lines. /// The range of the inserted text. @discardableResult @@ -102,7 +102,7 @@ extension EditorTextView { // MARK: - Paste as Plain Text /// Shows a button just below `range`, what a converted paste inserted, - /// that puts `plainText` there instead (FR-31). It never takes focus, + /// that puts `plainText` there instead. It never takes focus, /// so typing goes on in the editor. func showPlainTextButton(replacing range: NSRange, with plainText: String) { dismissPlainTextButton() @@ -156,8 +156,8 @@ extension EditorTextView { breakUndoCoalescing() } - /// Removes the button, and lets go of the pasted range and plain text - /// (FR-32). It stays until then: there's no timeout. + /// Removes the button, and lets go of the pasted range and plain text. + /// It stays until then: there's no timeout. func dismissPlainTextButton() { guard let button = plainTextButton else { return } button.removeFromSuperview() @@ -215,7 +215,7 @@ extension EditorTextView { // MARK: - Code blocks - /// Whether `location` is inside a fenced or indented code block (FR-5): + /// Whether `location` is inside a fenced or indented code block: /// by scanning the fences above it, which also works when the latest /// parse is behind the text, or, for indented code, from the parse. func isInCodeBlock(_ location: Int) -> Bool { diff --git a/Sources/MacDownKit/Editor/EditorTextView.swift b/Sources/MacDownKit/Editor/EditorTextView.swift index 3544687..d82f330 100644 --- a/Sources/MacDownKit/Editor/EditorTextView.swift +++ b/Sources/MacDownKit/Editor/EditorTextView.swift @@ -31,15 +31,15 @@ public final class EditorTextView: NSTextView { /// where code blocks are when pasting (see EditorTextView+Paste.swift). var documentBlocks: (source: String, blocks: [MarkdownDocumentModel.Block])? - /// Whether Paste converts formatted text to Markdown (FR-27), and how + /// Whether Paste converts formatted text to Markdown, and how /// it writes it: the writer's list marker and indentation. public var convertsPastedFormatting = true public var pasteOptions = HTMLToMarkdown.Options() /// Set during Paste and Match Style, which reads through the same - /// method as Paste but always pastes plain text (FR-4). + /// method as Paste but always pastes plain text. var pastesPlainText = false /// After a converted paste: the "Paste as Plain Text" button, and what - /// the paste inserted and the plain text to put there instead (FR-31). + /// the paste inserted and the plain text to put there instead. var plainTextButton: NSButton? var pastedPlainText: (range: NSRange, inserted: String, text: String)? diff --git a/Sources/MacDownKit/Editor/ImageMarkup.swift b/Sources/MacDownKit/Editor/ImageMarkup.swift index 57e7d8a..653f465 100644 --- a/Sources/MacDownKit/Editor/ImageMarkup.swift +++ b/Sources/MacDownKit/Editor/ImageMarkup.swift @@ -3,7 +3,7 @@ // MacDown // // Images embedded in the document as data URIs: image files dropped on the -// editor, and image data pasted into it (paste intent, FR-33). +// editor, and image data pasted into it. // import Foundation diff --git a/Sources/MacDownKit/Editor/MarkdownHighlighter.swift b/Sources/MacDownKit/Editor/MarkdownHighlighter.swift index 2be254a..bab7059 100644 --- a/Sources/MacDownKit/Editor/MarkdownHighlighter.swift +++ b/Sources/MacDownKit/Editor/MarkdownHighlighter.swift @@ -3,12 +3,12 @@ // MacDown // // Swift port of HGMarkdownHighlighter and HGMarkdownHighlightingStyle from -// PEG Markdown Highlight (Copyright 2011-2013 Ali Rantakari, MIT/GPL2+). -// The PEG parser and stylesheet parser remain in C (CPegMarkdown). +// PEG Markdown Highlight (Copyright 2011-2013 Ali Rantakari, MIT/GPL2+; see +// Licenses/peg-markdown-highlight.txt). The spans now come from the +// cmark-gfm document model; PEG's C parser is no longer used. // import AppKit -import CPegMarkdown /// A single highlighted span, in UTF-16 offsets. struct HighlightSpan: Sendable { @@ -17,63 +17,19 @@ struct HighlightSpan: Sendable { var address: String? } -/// Parsed spans, indexed by `pmh_element_type` raw value. +/// The element types themes style and the highlighter highlights: PEG +/// Markdown Highlight's (`pmh_element_type`, in its order, which the themes' +/// names follow; see `ThemeStyle.elementNames`), then those it didn't have. +enum HighlightElement: Int, CaseIterable { + case link, autoLinkURL, autoLinkEmail, image, code, html, htmlEntity, emph, strong + case listBullet, listEnumerator, comment, h1, h2, h3, h4, h5, h6, blockquote, verbatim + case htmlBlock, hrule, reference, note, math, highlight, superscript +} + +/// Highlight spans, indexed by `HighlightElement` raw value. They come from +/// the document model (`HighlightMapper`). struct HighlightElements: Sendable { var spans: [[HighlightSpan]] - - static func parse(_ markdown: String, extensions: Int32) -> HighlightElements { - var result: UnsafeMutablePointer?>? - markdown.withCString { cString in - pmh_markdown_to_elements(UnsafeMutablePointer(mutating: cString), - extensions, &result) - } - guard let result else { - return HighlightElements(spans: Array(repeating: [], - count: Int(pmh_NUM_LANG_TYPES))) - } - pmh_sort_elements_by_pos(result) - defer { pmh_free_elements(result) } - - // The parser reports Unicode code point offsets; NSString uses UTF-16. - // Gather indexes of surrogate pairs to convert. - let utf16 = Array(markdown.utf16) - var surrogatePairIndexes: [Int] = [] - for (i, unit) in utf16.enumerated() where UTF16.isLeadSurrogate(unit) { - surrogatePairIndexes.append(i) - } - - var spans: [[HighlightSpan]] = [] - for langType in 0.. Int { Int(type.rawValue) } + func t(_ type: HighlightElement) -> Int { type.rawValue } var styles: [HighlightingStyle] = [] - for h in [pmh_H1, pmh_H2, pmh_H3, pmh_H4, pmh_H5, pmh_H6] { + for h in [HighlightElement.h1, .h2, .h3, .h4, .h5, .h6] { styles.append(.init(elementType: t(h), foreground: dark(blue), background: light(blue), traits: .boldFontMask)) } styles += [ - .init(elementType: t(pmh_HRULE), foreground: darkGray, background: lightGray), - .init(elementType: t(pmh_LIST_BULLET), foreground: dark(magenta)), - .init(elementType: t(pmh_LIST_ENUMERATOR), foreground: dark(magenta)), - .init(elementType: t(pmh_LINK), foreground: dark(cyan), background: light(cyan)), - .init(elementType: t(pmh_AUTO_LINK_URL), foreground: dark(cyan), background: light(cyan)), - .init(elementType: t(pmh_AUTO_LINK_EMAIL), foreground: dark(cyan), background: light(cyan)), - .init(elementType: t(pmh_IMAGE), foreground: dark(magenta), background: light(magenta)), - .init(elementType: t(pmh_REFERENCE), foreground: dim(red)), - .init(elementType: t(pmh_CODE), foreground: dark(green), background: light(green)), - .init(elementType: t(pmh_EMPH), foreground: dark(yellow), traits: .italicFontMask), - .init(elementType: t(pmh_STRONG), foreground: dark(magenta), traits: .boldFontMask), - .init(elementType: t(pmh_HTML_ENTITY), foreground: medGray), - .init(elementType: t(pmh_COMMENT), foreground: medGray), - .init(elementType: t(pmh_VERBATIM), foreground: dark(green), background: light(green)), - .init(elementType: t(pmh_BLOCKQUOTE), foreground: dark(magenta), + .init(elementType: t(.hrule), foreground: darkGray, background: lightGray), + .init(elementType: t(.listBullet), foreground: dark(magenta)), + .init(elementType: t(.listEnumerator), foreground: dark(magenta)), + .init(elementType: t(.link), foreground: dark(cyan), background: light(cyan)), + .init(elementType: t(.autoLinkURL), foreground: dark(cyan), background: light(cyan)), + .init(elementType: t(.autoLinkEmail), foreground: dark(cyan), background: light(cyan)), + .init(elementType: t(.image), foreground: dark(magenta), background: light(magenta)), + .init(elementType: t(.reference), foreground: dim(red)), + .init(elementType: t(.code), foreground: dark(green), background: light(green)), + .init(elementType: t(.emph), foreground: dark(yellow), traits: .italicFontMask), + .init(elementType: t(.strong), foreground: dark(magenta), traits: .boldFontMask), + .init(elementType: t(.htmlEntity), foreground: medGray), + .init(elementType: t(.comment), foreground: medGray), + .init(elementType: t(.verbatim), foreground: dark(green), background: light(green)), + .init(elementType: t(.blockquote), foreground: dark(magenta), traits: .unboldFontMask), ] return styles @@ -182,14 +138,9 @@ public final class MarkdownHighlighter { public weak var textView: NSTextView? { didSet { if textView != nil { readClearTextStylesFromTextView() } } } - public var extensions: Int32 = Int32(pmh_EXT_NONE.rawValue) - public var waitInterval: TimeInterval = 0 public var resetTypingAttributes = true public var makeLinksClickable = false public private(set) var isActive = false - /// Spans come from elsewhere (the swift-markdown document model, via - /// `update(_:)`) instead of the highlighter's own PEG parse. - public var usesExternalElements = false /// Whether the idle pass is styling the rest of the document. Its storage /// edits come a chunk at a time; layout-dependent work can wait for /// `onIdlePassFinished` instead of following each one. @@ -209,7 +160,6 @@ public final class MarkdownHighlighter { private var defaultTextSize: CGFloat = 0 private var defaultTextColor: NSColor? private var defaultTypingAttributes: [NSAttributedString.Key: Any] = [:] - private var parseGeneration = 0 /// Character ranges styled with `cachedElements`. private(set) var highlightedRanges = IndexSet() private var isHighlighting = false @@ -224,31 +174,10 @@ public final class MarkdownHighlighter { if textView != nil { readClearTextStylesFromTextView() } } - // MARK: - Parsing - - func requestParsing() { - guard let textView, !usesExternalElements else { return } - parseGeneration += 1 - let generation = parseGeneration - let markdown = textView.string - let extensions = self.extensions - Task { [weak self] in - let elements = await Task.detached(priority: .userInitiated) { - HighlightElements.parse(markdown, extensions: extensions) - }.value - guard let self, self.isActive, generation == self.parseGeneration - else { return } - self.setElements(elements) - } - } - - public func parseAndHighlightNow() { - requestParsing() - } + // MARK: - Spans - /// Highlights with spans parsed elsewhere, for the current text. + /// Highlights with the document model's spans for the current text. func update(_ elements: HighlightElements) { - parseGeneration += 1 // Any PEG parse in flight is stale. if isActive { setElements(elements) } else { @@ -343,8 +272,7 @@ public final class MarkdownHighlighter { clearHighlighting(in: range) let sourceLength = storage.length - let linkTypes = [pmh_LINK, pmh_AUTO_LINK_URL, pmh_AUTO_LINK_EMAIL] - .map { Int($0.rawValue) } + let linkTypes = [HighlightElement.link, .autoLinkURL, .autoLinkEmail].map(\.rawValue) for style in styles { guard style.elementType < elements.spans.count else { continue } for span in elements.spans[style.elementType] { @@ -360,7 +288,7 @@ public final class MarkdownHighlighter { if makeLinksClickable, linkTypes.contains(style.elementType), var address = span.address { - if style.elementType == Int(pmh_AUTO_LINK_EMAIL.rawValue), + if style.elementType == HighlightElement.autoLinkEmail.rawValue, !address.hasPrefix("mailto:") { address = "mailto:" + address } @@ -583,7 +511,7 @@ public final class MarkdownHighlighter { private func applyStyleDependencies() { guard let textView else { return } // Make link styles match the styles set for LINK elements. - if let style = styles.first(where: { $0.elementType == Int(pmh_LINK.rawValue) }) { + if let style = styles.first(where: { $0.elementType == HighlightElement.link.rawValue }) { var attrs = style.attributesToAdd attrs[.cursor] = NSCursor.pointingHand textView.linkTextAttributes = attrs @@ -652,14 +580,9 @@ public final class MarkdownHighlighter { guard let textView else { return } applyStyleDependencies() isActive = true - requestParsing() + if cachedElements != nil { highlightVisibleRange() } let center = NotificationCenter.default - observers.append(center.addObserver( - forName: NSText.didChangeNotification, object: textView, queue: .main - ) { [weak self] _ in - MainActor.assumeIsolated { self?.textDidChange() } - }) // Edits move the text, so what was highlighted no longer lines up. // Posted synchronously, while `editedMask` is valid, and for // programmatic changes too. @@ -697,23 +620,12 @@ public final class MarkdownHighlighter { guard isActive else { return } observers.forEach(NotificationCenter.default.removeObserver) observers.removeAll() - cachedElements = nil + // The spans are kept: they're the model's, for the current text, + // and restyle the editor when it's activated again. highlightedRanges = IndexSet() - parseGeneration += 1 isActive = false } - private func textDidChange() { - if waitInterval <= 0 { - requestParsing() - } else { - DispatchQueue.main.asyncAfter(deadline: .now() + waitInterval) { - [weak self] in - MainActor.assumeIsolated { self?.requestParsing() } - } - } - } - private func textViewDidScroll() { // Style newly revealed text right away, before it's drawn; mostly // it's already styled by the overscan or the idle pass. diff --git a/Sources/MacDownKit/Editor/PasteboardContent.swift b/Sources/MacDownKit/Editor/PasteboardContent.swift index 578f7ec..cf0cd76 100644 --- a/Sources/MacDownKit/Editor/PasteboardContent.swift +++ b/Sources/MacDownKit/Editor/PasteboardContent.swift @@ -20,8 +20,8 @@ enum PasteboardContent: Equatable { static let jpeg = NSPasteboard.PasteboardType("public.jpeg") /// The clipboard's formatted text or image, in order of preference: - /// HTML (or a web archive), then rich text (FR-1, FR-2), then image - /// data when there's no text at all (FR-33). Nil for plain text. + /// HTML (or a web archive), then rich text, then image + /// data when there's no text at all. Nil for plain text. @MainActor static func read(from pasteboard: NSPasteboard) -> PasteboardContent? { let types = pasteboard.types ?? [] let archive = types.contains(webArchive) ? pasteboard.data(forType: webArchive).flatMap(mainResource) : nil diff --git a/Sources/MacDownKit/Editor/ThemeStyleParser.swift b/Sources/MacDownKit/Editor/ThemeStyleParser.swift index 79a47a0..50637c7 100644 --- a/Sources/MacDownKit/Editor/ThemeStyleParser.swift +++ b/Sources/MacDownKit/Editor/ThemeStyleParser.swift @@ -3,8 +3,9 @@ // MacDownKit // // Parses editor themes (`.style` files) — a Swift port of PEG Markdown -// Highlight's pmh_styleparser.c, so the themes keep working once the C -// library is gone (swift-markdown migration, Phase 2). Element names, +// Highlight's pmh_styleparser.c (Copyright 2011 Ali Rantakari; see +// Licenses/peg-markdown-highlight.txt), so the themes keep working without +// the C library, which MacDown no longer uses. Element names, // attributes, colors, font traits and error messages are the same, as are // the C parser's quirks: a rule's attributes come out in reverse order, // and a later `editor`, `editor-current-line` or `editor-selection` rule diff --git a/Sources/MacDownKit/Preferences/PreferenceSettingKey.swift b/Sources/MacDownKit/Preferences/PreferenceSettingKey.swift index 87f01ad..6eba4fc 100644 --- a/Sources/MacDownKit/Preferences/PreferenceSettingKey.swift +++ b/Sources/MacDownKit/Preferences/PreferenceSettingKey.swift @@ -23,8 +23,6 @@ public enum PreferenceSettingKey: String, CaseIterable, Sendable { case extensionHighlight case extensionSmartyPants case markdownManualRender - /// Hidden: the Markdown engine (cmark-gfm or hoedown). - case markdownEngine // MARK: Editor case editorBaseFontInfo @@ -84,8 +82,8 @@ public enum PreferenceSettingKey: String, CaseIterable, Sendable { // MARK: Retired // Settings that are no longer read: standard Markdown is always on, and - // Quote and Underline are gone. Their saved values are left in place - // (FR-36), so a downgrade still finds them. + // Quote and Underline are gone. Their saved values are left in place, + // so a downgrade still finds them. case extensionTables case extensionFencedCode case extensionFootnotes diff --git a/Sources/MacDownKit/Preferences/Preferences.swift b/Sources/MacDownKit/Preferences/Preferences.swift index 2c7289f..08f2b71 100644 --- a/Sources/MacDownKit/Preferences/Preferences.swift +++ b/Sources/MacDownKit/Preferences/Preferences.swift @@ -23,15 +23,6 @@ public extension Notification.Name { static let didRequestPreviewRender = Notification.Name("MPDidRequestPreviewRender") } -/// The Markdown parser behind the preview and highlighting. -/// `cmarkGfm` is cmark-gfm, the default; `hoedown` is the -/// original's engine, kept selectable for one release before it's removed -/// (docs/intents/swift-markdown-migration.md, Phase 5). Hidden: set with -/// `defaults write io.github.levous.macdown-swift markdownEngine hoedown`. -public enum MarkdownEngine: String, CaseIterable, Sendable { - case hoedown, cmarkGfm -} - public enum UnorderedListMarkerType: Int, CaseIterable, Sendable { case asterisk = 0, plusSign, minusSign @@ -124,8 +115,7 @@ public final class Preferences { public var previewZoomRelativeToBaseFontSize = false { didSet { save(previewZoomRelativeToBaseFontSize, .previewZoomRelativeToBaseFontSize) } } - /// Not shown in Settings (FR-32). - public var markdownEngine = MarkdownEngine.cmarkGfm { didSet { save(markdownEngine.rawValue, .markdownEngine) } } + /// Not shown in Settings. // MARK: HTML rendering @@ -290,7 +280,6 @@ public final class Preferences { editorConvertsPastedFormatting = d.bool(forKey: .editorConvertsPastedFormatting) previewZoomRelativeToBaseFontSize = d.bool(forKey: .previewZoomRelativeToBaseFontSize) - markdownEngine = d.string(forKey: .markdownEngine).flatMap(MarkdownEngine.init) ?? .cmarkGfm htmlTemplateName = d.string(forKey: .htmlTemplateName) htmlStyleName = d.string(forKey: .htmlStyleName) htmlHardWrap = d.bool(forKey: .htmlHardWrap) diff --git a/Sources/MacDownKit/Preview/PreviewController.swift b/Sources/MacDownKit/Preview/PreviewController.swift index 180dab5..b1df504 100644 --- a/Sources/MacDownKit/Preview/PreviewController.swift +++ b/Sources/MacDownKit/Preview/PreviewController.swift @@ -28,7 +28,7 @@ public struct TextCount: Equatable, Sendable { } public struct PreviewMetrics: Sendable { - /// Scroll sync anchors, in CSS pixels; see `ScrollAnchors`. + /// Scroll sync anchors (blocks' source lines), in CSS pixels. public var anchors: [ScrollAnchor] = [] public var contentHeight: CGFloat = 0 public var visibleHeight: CGFloat = 0 @@ -284,44 +284,14 @@ public final class PreviewController: NSObject { } public func fetchMetrics() async -> PreviewMetrics { - // The new engine marks blocks with their source line: report each - // one's top. Otherwise mirror ScrollAnchors.scan: top-level headers, - // and images in top-level paragraphs that contain nothing else. + // Every block is marked with its source line: report each one's top. let script = """ (function () { var anchors = []; var lines = document.querySelectorAll("[data-source-line]"); - if (lines.length > 0) { - Array.prototype.forEach.call(lines, function (node) { - anchors.push(["l", node.getBoundingClientRect().top + window.scrollY, - parseInt(node.getAttribute("data-source-line"), 10)]); - }); - return JSON.stringify({ - anchors: anchors, - contentHeight: document.documentElement.scrollHeight, - visibleHeight: window.innerHeight - }); - } - function add(kind, node) { - var rect = node.getBoundingClientRect(); - anchors.push([kind, rect.top + window.scrollY + rect.height / 2]); - } - // The body, unless a custom template wraps it. - var first = document.querySelector("h1, h2, h3, h4, h5, h6, p"); - var container = (first && first.parentElement) || document.body; - Array.prototype.forEach.call(container.children, function (node) { - if (/^H[1-6]$/.test(node.tagName)) { - add("h", node); - } else if (node.tagName === "P" && node.textContent.trim() === "" - && node.querySelector("img")) { - var children = Array.prototype.slice.call(node.children); - if (children.every(function (c) { - return c.tagName === "IMG" || c.tagName === "BR"; })) { - children.forEach(function (c) { - if (c.tagName === "IMG") add("i", c); - }); - } - } + Array.prototype.forEach.call(lines, function (node) { + anchors.push([parseInt(node.getAttribute("data-source-line"), 10), + node.getBoundingClientRect().top + window.scrollY]); }); return JSON.stringify({ anchors: anchors, @@ -337,13 +307,9 @@ public final class PreviewController: NSObject { else { return PreviewMetrics() } var metrics = PreviewMetrics() metrics.anchors = (object["anchors"] as? [[Any]] ?? []).compactMap { - guard $0.count >= 2, let kind = $0[0] as? String, - let y = $0[1] as? NSNumber else { return nil } - if kind == "l" { - guard $0.count == 3, let line = $0[2] as? NSNumber else { return nil } - return ScrollAnchor(.line(line.intValue), CGFloat(y.doubleValue)) - } - return ScrollAnchor(kind == "h" ? .header : .image, CGFloat(y.doubleValue)) + guard $0.count == 2, let line = $0[0] as? NSNumber, let y = $0[1] as? NSNumber + else { return nil } + return ScrollAnchor(line: line.intValue, CGFloat(y.doubleValue)) } metrics.contentHeight = CGFloat((object["contentHeight"] as? NSNumber)? .doubleValue ?? 0) diff --git a/Sources/MacDownKit/Resources/Extensions/mermaid.init.js b/Sources/MacDownKit/Resources/Extensions/mermaid.init.js index 632cc53..93ffd12 100644 --- a/Sources/MacDownKit/Resources/Extensions/mermaid.init.js +++ b/Sources/MacDownKit/Resources/Extensions/mermaid.init.js @@ -1,6 +1,6 @@ // Renders ```mermaid code blocks as diagrams (Mermaid 12). // -// Each block is hoedown's

    ; the
    +// Each block is MacDown's 
    ; the
     // 
    is replaced with the diagram. The preview calls // MacDownMermaid.render() again after it replaces the page body in place. diff --git a/Tests/MacDownKitTests/CoreTests.swift b/Tests/MacDownKitTests/CoreTests.swift index 9bdc686..978797d 100644 --- a/Tests/MacDownKitTests/CoreTests.swift +++ b/Tests/MacDownKitTests/CoreTests.swift @@ -8,7 +8,6 @@ import AppKit import Foundation import Testing -import CHoedown @testable import MacDownKit private func fixture(_ name: String, _ ext: String) -> URL { @@ -252,9 +251,9 @@ private func fixture(_ name: String, _ ext: String) -> URL { defaults.set(true, forKey: .extensionUnderline) let preferences = Preferences(defaults: defaults) preferences.extensionHighlight = true - let html = MarkdownParser.parse( + let html = MarkdownDocumentModel( "_italic_ __bold__ *italic* **bold** under ==mark==\n", - settings: preferences.renderSettings.parse).body + options: .init(preferences.renderSettings.parse)).body #expect(html.contains("italic bold italic bold")) #expect(html.contains("under")) #expect(html.contains("mark")) @@ -291,18 +290,20 @@ private func fixture(_ name: String, _ ext: String) -> URL { defaults.set(false, forKey: key) } defaults.set(true, forKey: .extensionQuote) - let flags = Preferences(defaults: defaults).extensionFlags - for flag in [HOEDOWN_EXT_TABLES, HOEDOWN_EXT_FENCED_CODE, HOEDOWN_EXT_FOOTNOTES, - HOEDOWN_EXT_STRIKETHROUGH] { - #expect(flags & flag.rawValue != 0, "\(flag) is off") + let settings = Preferences(defaults: defaults).renderSettings.parse + #expect(settings == ParseSettings()) + let html = MarkdownDocumentModel( + "| a |\n|---|\n| 1 |\n\n```\ncode\n```\n\nn[^1] ~~x~~ in*tra*word \"q\"\n\n[^1]: N.\n", + options: .init(settings)).body + for element in ["", "
    ", "class=\"footnotes\"", "x", "intraword"] {
    +            #expect(html.contains(element), "missing \(element)")
             }
    -        // Intra-word emphasis on (no NO_INTRA_EMPHASIS); Quote is dropped.
    -        #expect(flags & HOEDOWN_EXT_NO_INTRA_EMPHASIS.rawValue == 0)
    -        #expect(flags & HOEDOWN_EXT_QUOTE.rawValue == 0)
    +        // Quote is dropped.
    +        #expect(!html.contains(""))
         }
     
         /// Converting pasted formatting is on for new installs and for existing
    -    /// ones that predate it, and stays off once turned off (FR-27).
    +    /// ones that predate it, and stays off once turned off.
         @Test func convertsPastedFormattingByDefault() throws {
             for existing in [false, true] {
                 let suite = "MacDownTests-\(UUID().uuidString)"
    @@ -316,22 +317,6 @@ private func fixture(_ name: String, _ ext: String) -> URL {
             }
         }
     
    -    /// The hidden engine switch for the swift-markdown migration (FR-32).
    -    @Test func markdownEngine() throws {
    -        let suite = "MacDownTests-\(UUID().uuidString)"
    -        let defaults = try #require(UserDefaults(suiteName: suite))
    -        defer { defaults.removePersistentDomain(forName: suite) }
    -        // cmark-gfm ("cmarkGfm") is the default; hoedown stays selectable.
    -        #expect(Preferences(defaults: defaults).markdownEngine == .cmarkGfm)
    -        defaults.set("hoedown", forKey: .markdownEngine)
    -        #expect(Preferences(defaults: defaults).markdownEngine == .hoedown)
    -        defaults.set("bogus", forKey: .markdownEngine)
    -        #expect(Preferences(defaults: defaults).markdownEngine == .cmarkGfm)
    -        let preferences = Preferences(defaults: defaults)
    -        preferences.markdownEngine = .hoedown
    -        #expect(defaults.string(forKey: .markdownEngine) == "hoedown")
    -    }
    -
         /// New installs follow common Markdown editing conventions.
         @Test func freshInstallEditingDefaults() throws {
             let suite = "MacDownTests-\(UUID().uuidString)"
    @@ -382,7 +367,7 @@ private func fixture(_ name: String, _ ext: String) -> URL {
         }
     
         /// Settings that became standard are no longer read, but their saved
    -    /// values stay in user defaults (FR-36), so a downgrade still finds them.
    +    /// values stay in user defaults, so a downgrade still finds them.
         @Test func removedSettingsKeepTheirSavedValues() throws {
             let suite = "MacDownTests-\(UUID().uuidString)"
             let defaults = try #require(UserDefaults(suiteName: suite))
    @@ -405,41 +390,35 @@ private func fixture(_ name: String, _ ext: String) -> URL {
             defaults.set(false, forKey: .htmlTaskList)
             defaults.set(false, forKey: .htmlDetectFrontMatter)
             let settings = Preferences(defaults: defaults).renderSettings
    -        #expect(settings.parse.rendererFlags & UInt32(HOEDOWN_HTML_USE_TASK_LIST) != 0)
             #expect(settings.page.taskList)    // The checkbox script.
    -        #expect(settings.parse.detectsFrontMatter)
     
    -        let html = MarkdownParser.parse("---\ntitle: Notes\n---\n\n- [x] done\n",
    -                                        settings: settings.parse).body
    +        let html = MarkdownDocumentModel("---\ntitle: Notes\n---\n\n- [x] done\n",
    +                                         options: .init(settings.parse)).body
             #expect(html.contains("
    ") && html.contains("Notes")) #expect(html.contains(#"type="checkbox""#)) } } @Suite struct RendererTests { - func parse(_ engine: MarkdownEngine, _ text: String, ext: UInt32 = 0x7 | (1 << 4), - renderer: UInt32 = 0, toc: Bool = false, frontMatter: Bool = false) -> ParseResult { - let settings = ParseSettings(extensionFlags: ext, rendererFlags: renderer, - rendersTOC: toc, detectsFrontMatter: frontMatter) - switch engine { - case .hoedown: - return MarkdownParser.parse(text, settings: settings) - case .cmarkGfm: - let model = MarkdownDocumentModel(text, options: .init(settings)) - return ParseResult(body: model.body, languages: model.languages) - } - } - - @Test(arguments: MarkdownEngine.allCases) - func basic(_ engine: MarkdownEngine) { - let result = parse(engine, "# Hello\n\n*world*") + func parse(_ text: String, codeInformation: Bool = false, toc: Bool = false) -> ParseResult { + var settings = ParseSettings() + settings.lineNumbers = codeInformation + settings.blockCodeInformation = codeInformation + settings.rendersTOC = toc + let model = MarkdownDocumentModel(text, options: .init(settings)) + return ParseResult(body: model.body, languages: model.languages) + } + + @Test + func basic() { + let result = parse("# Hello\n\n*world*") #expect(result.body.contains("

    Hello

    ")) #expect(result.body.contains("world")) } - @Test(arguments: MarkdownEngine.allCases) - func fencedCodeMapsAliasesAndCollectsLanguages(_ engine: MarkdownEngine) { - let result = parse(engine, "```js\nvar a = 1;\n```\n\n```c++\nint x;\n```\n") + @Test + func fencedCodeMapsAliasesAndCollectsLanguages() { + let result = parse("```js\nvar a = 1;\n```\n\n```c++\nint x;\n```\n") #expect(result.body.contains("var a = 1;")) #expect(result.body.contains("
    "))
             #expect(result.languages.contains("javascript"))
    @@ -478,9 +457,8 @@ private func fixture(_ name: String, _ ext: String) -> URL {
     
                 [^n]: The note.
                 """
    -        // Both engines.
    -        for html in [MarkdownParser.parse(text, settings: settings).body,
    -                     MarkdownDocumentModel(text, options: .init(settings)).body] {
    +        do {
    +            let html = MarkdownDocumentModel(text, options: .init(settings)).body
                 for element in ["
    ", "
    Standard
    ", "", "", #""#, "gone", #"
    "#, #"type="checkbox""#, @@ -491,55 +469,54 @@ private func fixture(_ name: String, _ ext: String) -> URL { } } - @Test(arguments: MarkdownEngine.allCases) - func noLanguage(_ engine: MarkdownEngine) { - let result = parse(engine, "```\nplain\n```\n") + @Test + func noLanguage() { + let result = parse("```\nplain\n```\n") #expect(result.body.contains("plain")) } - @Test(arguments: MarkdownEngine.allCases) - func taskList(_ engine: MarkdownEngine) { - let result = parse(engine, "- [ ] todo\n- [x] done\n", renderer: 1 << 4) + @Test + func taskList() { + let result = parse("- [ ] todo\n- [x] done\n") #expect(result.body.contains("
  • todo")) #expect(result.body.contains(" done")) } - @Test(arguments: MarkdownEngine.allCases) - func lineNumbersAndInformation(_ engine: MarkdownEngine) { - let result = parse(engine, "```python:example.py\nprint(1)\n```\n", - renderer: (1 << 5) | (1 << 6)) + @Test + func lineNumbersAndInformation() { + let result = parse("```python:example.py\nprint(1)\n```\n", codeInformation: true) #expect(result.body.contains( "
    "))
         }
     
    -    @Test(arguments: MarkdownEngine.allCases)
    -    func tableOfContents(_ engine: MarkdownEngine) {
    -        let result = parse(engine, "[TOC]\n\n# One\n\n## Two\n", toc: true)
    +    @Test
    +    func tableOfContents() {
    +        let result = parse("[TOC]\n\n# One\n\n## Two\n", toc: true)
             #expect(result.body.contains("
      ")) #expect(result.body.contains("Two")) #expect(!result.body.contains("[TOC]")) } - @Test(arguments: MarkdownEngine.allCases) - func frontMatter(_ engine: MarkdownEngine) { - let result = parse(engine, "---\ntitle: Test\n---\nBody", frontMatter: true) + @Test + func frontMatter() { + let result = parse("---\ntitle: Test\n---\nBody") #expect(result.body.hasPrefix( "
  • a1
    title
    Test
    \n")) #expect(result.body.contains("

    Body

    ")) } - @Test(arguments: MarkdownEngine.allCases) - func unicode(_ engine: MarkdownEngine) { - let result = parse(engine, "# 中文 😀\n") + @Test + func unicode() { + let result = parse("# 中文 😀\n") #expect(result.body.contains("中文 😀")) } - @Test(arguments: MarkdownEngine.allCases) - func previewPage(_ engine: MarkdownEngine) { + @Test + func previewPage() { var settings = PageSettings() settings.syntaxHighlighting = true settings.lineNumbers = true - let result = parse(engine, "```swift\nlet a = 1\n```\n") + let result = parse("```swift\nlet a = 1\n```\n") let html = PageBuilder.previewHTML(title: "Doc", result: result, settings: settings) #expect(html.contains("Doc")) @@ -549,11 +526,11 @@ private func fixture(_ name: String, _ ext: String) -> URL { #expect(html.contains("prism.css")) } - @Test(arguments: MarkdownEngine.allCases) - func exportPageIsSelfContained(_ engine: MarkdownEngine) { + @Test + func exportPageIsSelfContained() { var settings = PageSettings() settings.syntaxHighlighting = true - let result = parse(engine, "```swift\nlet a = 1\n```\n") + let result = parse("```swift\nlet a = 1\n```\n") let html = PageBuilder.exportHTML(title: nil, result: result, settings: settings, withStyles: false, withHighlighting: true) diff --git a/Tests/MacDownKitTests/CorpusTests.swift b/Tests/MacDownKitTests/CorpusTests.swift index bcc2a82..801d211 100644 --- a/Tests/MacDownKitTests/CorpusTests.swift +++ b/Tests/MacDownKitTests/CorpusTests.swift @@ -2,7 +2,7 @@ // CorpusTests.swift // MacDownKitTests // -// The migration corpus (TR-9): purpose-written Markdown in +// The migration corpus: purpose-written Markdown in // Resources/Corpus, one file per feature area with its edge cases, plus the // bundled help.md and a generated 10k-line document. The HTML and // highlight-span diff harnesses run over every document here. Never add @@ -50,7 +50,7 @@ enum Corpus { } /// A long document cycling through the common block types, for - /// performance checks (NFR-1). Deterministic, exactly `lines` lines. + /// performance checks. Deterministic, exactly `lines` lines. static func generated(lines: Int) -> String { let blocks = [ ["## Section %d", ""], @@ -86,7 +86,7 @@ enum Corpus { }() func render(_ text: String) -> String { - MarkdownParser.parse(text, settings: Self.settings).body + MarkdownDocumentModel(text, options: .init(Self.settings)).body } @Test func coversEveryArea() throws { @@ -97,7 +97,7 @@ enum Corpus { } @Test(arguments: try Corpus.all()) - func everyDocumentParsesWithBothEngines(_ document: Corpus.Document) { + func everyDocumentRenders(_ document: Corpus.Document) { #expect(!render(document.text).isEmpty) #expect(CMarkTree(document.text).withRoot { !$0.children.isEmpty }) } diff --git a/Tests/MacDownKitTests/DocumentControllerTests.swift b/Tests/MacDownKitTests/DocumentControllerTests.swift index 6bf95f9..bcfdbe1 100644 --- a/Tests/MacDownKitTests/DocumentControllerTests.swift +++ b/Tests/MacDownKitTests/DocumentControllerTests.swift @@ -56,7 +56,7 @@ extension LiveDocumentTests { #expect(controller.html.contains("id=\"toc_0\">Second")) } - /// After a parse, the editor knows where the code blocks are (FR-5). + /// After a parse, the editor knows where the code blocks are. @Test func editorLearnsCodeBlocksFromTheParse() async { let text = "Text\n\n indented code\n" let (controller, window) = makeController(text) @@ -425,14 +425,10 @@ extension LiveDocumentTests { @Test func clickingTaskListCheckboxesEditsTheMarkdown() async throws { let preferences = Preferences.shared - let (engine, toggling, autosaves) = (preferences.markdownEngine, - preferences.htmlTaskListToggling, - preferences.autosavesDocuments) - preferences.markdownEngine = .cmarkGfm + let (toggling, autosaves) = (preferences.htmlTaskListToggling, preferences.autosavesDocuments) preferences.htmlTaskListToggling = true preferences.autosavesDocuments = false defer { - preferences.markdownEngine = engine preferences.htmlTaskListToggling = toggling preferences.autosavesDocuments = autosaves } diff --git a/Tests/MacDownKitTests/EditorTests.swift b/Tests/MacDownKitTests/EditorTests.swift index d27759c..f3ff880 100644 --- a/Tests/MacDownKitTests/EditorTests.swift +++ b/Tests/MacDownKitTests/EditorTests.swift @@ -4,7 +4,6 @@ // import AppKit -import CPegMarkdown import Testing @testable import MacDownKit @@ -16,57 +15,74 @@ func isPureRed(_ color: NSColor?) -> Bool { return color.redComponent == 1 && color.greenComponent == 0 && color.blueComponent == 0 } -/// Highlight spans from either engine: PEG, or the swift-markdown model. -func highlightElements(_ text: String, engine: MarkdownEngine) -> HighlightElements { - switch engine { - case .hoedown: HighlightElements.parse(text, extensions: Int32(pmh_EXT_NOTES.rawValue)) - case .cmarkGfm: MarkdownDocumentModel(text, options: .init()).highlights - } +/// The document model's highlight spans for `text`. +func highlightElements(_ text: String) -> HighlightElements { + MarkdownDocumentModel(text, options: .init()).highlights } @Suite struct HighlighterTests { - @Test(arguments: MarkdownEngine.allCases) - func parsesElements(_ engine: MarkdownEngine) { - let elements = highlightElements("# Title\n\n*em* and **strong**\n", engine: engine) - #expect(elements.spans[Int(pmh_H1.rawValue)].count == 1) - #expect(elements.spans[Int(pmh_EMPH.rawValue)].count == 1) - #expect(elements.spans[Int(pmh_STRONG.rawValue)].count == 1) - } - - @Test(arguments: MarkdownEngine.allCases) - func convertsSurrogatePairOffsets(_ engine: MarkdownEngine) { - let elements = highlightElements("😀 *em*\n", engine: engine) - let span = elements.spans[Int(pmh_EMPH.rawValue)].first + @Test + func parsesElements() { + let elements = highlightElements("# Title\n\n*em* and **strong**\n") + #expect(elements.spans[HighlightElement.h1.rawValue].count == 1) + #expect(elements.spans[HighlightElement.emph.rawValue].count == 1) + #expect(elements.spans[HighlightElement.strong.rawValue].count == 1) + } + + /// The element types index the themes' element names. + @Test func elementTypesFollowTheThemeNames() { + #expect(HighlightElement.allCases.count == ThemeStyle.elementNames.count) + for (element, name) in [(HighlightElement.link, "LINK"), (.autoLinkEmail, "AUTO_LINK_EMAIL"), + (.h1, "H1"), (.h6, "H6"), (.htmlBlock, "HTMLBLOCK"), (.note, "NOTE"), + (.superscript, "SUPERSCRIPT")] { + #expect(ThemeStyle.elementNames[element.rawValue] == name) + } + } + + /// Footnotes are standard, so they're always highlighted. + @Test func footnotes() { + #expect(!highlightElements("a[^1]\n\n[^1]: b\n").spans[HighlightElement.note.rawValue].isEmpty) + } + + @Test + func convertsSurrogatePairOffsets() { + let elements = highlightElements("😀 *em*\n") + let span = elements.spans[HighlightElement.emph.rawValue].first // "😀" is two UTF-16 units; "*em*" starts at UTF-16 offset 3. #expect(span?.pos == 3) #expect(span?.end == 7) } - @MainActor @Test(arguments: MarkdownEngine.allCases) - func appliesStylesToTextView(_ engine: MarkdownEngine) async throws { + @MainActor @Test + func appliesStylesToTextView() async throws { let (_, textView) = EditorTextView.makeScrollableEditor() textView.frame = NSRect(x: 0, y: 0, width: 400, height: 400) textView.string = "# Title\n\n*em*\n" let highlighter = MarkdownHighlighter(textView: textView) let errors = highlighter.applyStyles(fromStylesheet: "H1\nforeground: ff0000\n") #expect(errors.isEmpty) - highlighter.usesExternalElements = engine == .cmarkGfm highlighter.activate() - try await Task.sleep(for: .milliseconds(500)) - if engine == .cmarkGfm { - // As after a parse: spans arrive once the text is laid out. - highlighter.update(highlightElements(textView.string, engine: engine)) - } + // As after a parse: spans arrive once the text is laid out. + highlighter.update(highlightElements(textView.string)) func red() -> Bool { isPureRed(textView.textStorage?.attribute(.foregroundColor, at: 2, effectiveRange: nil) as? NSColor) } - // The hoedown engine parses in the background, which can take longer - // than the first wait while the rest of the suite runs in parallel. - let deadline = ContinuousClock.now + .seconds(5) - while !red(), ContinuousClock.now < deadline { - try await Task.sleep(for: .milliseconds(50)) + // Off screen nothing is visible, so the idle pass styles the text. + func waitForRed() async throws -> Bool { + let deadline = ContinuousClock.now + .seconds(5) + while !red(), ContinuousClock.now < deadline { + try await Task.sleep(for: .milliseconds(50)) + } + return red() } - #expect(red()) + #expect(try await waitForRed()) + // Settings changes deactivate and reactivate the highlighter, which + // restyles from the spans it has (there's no parse of its own). + highlighter.deactivate() + highlighter.clearHighlighting() + #expect(!red()) + highlighter.activate() + #expect(try await waitForRed()) } } @@ -88,7 +104,6 @@ func highlightElements(_ text: String, engine: MarkdownEngine) -> HighlightEleme textView.string = Self.text let highlighter = MarkdownHighlighter(textView: textView) highlighter.applyStyles(fromStylesheet: stylesheet) - highlighter.usesExternalElements = true highlighter.activate() return (highlighter, scrollView, textView, window) } @@ -112,7 +127,7 @@ func highlightElements(_ text: String, engine: MarkdownEngine) -> HighlightEleme let (highlighter, scrollView, textView, window) = makeHighlighter() defer { withExtendedLifetime(window) {} } highlighter.idleStartDate = .distantFuture // No idle pass. - highlighter.update(highlightElements(Self.text, engine: .cmarkGfm)) + highlighter.update(highlightElements(Self.text)) let far = location(of: "# Heading 150\n") + 2 #expect(!isRed(textView, at: far)) @@ -129,7 +144,7 @@ func highlightElements(_ text: String, engine: MarkdownEngine) -> HighlightEleme defer { withExtendedLifetime(window) {} } var finished = 0 highlighter.onIdlePassFinished = { finished += 1 } - highlighter.update(highlightElements(Self.text, engine: .cmarkGfm)) + highlighter.update(highlightElements(Self.text)) let length = (Self.text as NSString).length #expect(highlighter.highlightedRanges.count < length / 4) try await waitForIdlePass(highlighter, length: length) @@ -143,7 +158,7 @@ func highlightElements(_ text: String, engine: MarkdownEngine) -> HighlightEleme let (highlighter, _, textView, window) = makeHighlighter() defer { withExtendedLifetime(window) {} } highlighter.idleStartDate = .distantFuture - highlighter.update(highlightElements(Self.text, engine: .cmarkGfm)) + highlighter.update(highlightElements(Self.text)) #expect(!highlighter.highlightedRanges.isEmpty) // Directly, as typing would also scroll, and so highlight what's // visible again. @@ -156,7 +171,7 @@ func highlightElements(_ text: String, engine: MarkdownEngine) -> HighlightEleme defer { withExtendedLifetime(window) {} } scrollView.removeFromSuperview() scrollView.frame = .zero - highlighter.update(highlightElements(Self.text, engine: .cmarkGfm)) + highlighter.update(highlightElements(Self.text)) #expect(highlighter.highlightedRanges.isEmpty) let length = (Self.text as NSString).length try await waitForIdlePass(highlighter, length: length) @@ -175,7 +190,7 @@ func highlightElements(_ text: String, engine: MarkdownEngine) -> HighlightEleme return layoutManager.lineFragmentRect(forGlyphAt: glyph, effectiveRange: nil).minY - scrollView.contentView.bounds.minY } - highlighter.update(highlightElements(Self.text, engine: .cmarkGfm)) + highlighter.update(highlightElements(Self.text)) let before = top() try await waitForIdlePass(highlighter, length: (Self.text as NSString).length) // The headings above grew, yet the line stays where it was on screen. @@ -215,7 +230,7 @@ func highlightElements(_ text: String, engine: MarkdownEngine) -> HighlightEleme .first(where: { if case .backgroundColor = $0.value { true } else { false } })?.value else { Issue.record("no editor background"); return } #expect(textView.backgroundColor == HighlightingStyle.color(background)) - let h1 = try #require(highlighter.styles.first { $0.elementType == Int(pmh_H1.rawValue) }) + let h1 = try #require(highlighter.styles.first { $0.elementType == HighlightElement.h1.rawValue }) let rule = try #require(theme.elements.first { $0.element == "H1" }) let foreground = rule.attributes.compactMap { attribute -> ThemeStyle.Color? in if case .foregroundColor(let c) = attribute.value { c } else { nil } @@ -357,21 +372,7 @@ func highlightElements(_ text: String, engine: MarkdownEngine) -> HighlightEleme } } -extension LiveDocumentTests { -@MainActor @Suite struct EditorHighlightingSetupTests { - /// Footnotes are standard, so the editor always parses them (the old - /// `extensionFootnotes` setting had this inverted). - @Test func highlighterAlwaysParsesFootnotes() { - let controller = DocumentController(document: MarkdownDocument(text: "a[^1]\n\n[^1]: b\n"), - fileURL: nil) - defer { controller.tearDown() } - controller.setupEditor(nil) - #expect(controller.highlighter.extensions == Int32(pmh_EXT_NOTES.rawValue)) - } -} -} - -/// Images embedded as data URIs (dropped files, pasted data; FR-33). +/// Images embedded as data URIs (dropped files, pasted data). @Suite struct ImageMarkupTests { @Test func dataURI() { #expect(ImageMarkup.dataURI(Data([1, 2, 3]), mime: "image/png") == "![](data:image/png;base64,AQID)") @@ -391,7 +392,7 @@ extension LiveDocumentTests { } } -/// Pasting inside a code block pastes plain text (FR-5): the editor knows +/// Pasting inside a code block pastes plain text: the editor knows /// where code blocks are from the latest parse, or by scanning for fences /// when the parse is behind the text. @MainActor @Suite struct EditorCodeBlockTests { @@ -447,8 +448,8 @@ extension EditorCodeBlockTests { } } -/// Pasting formatted text and images (FR-1 to FR-3, FR-6, FR-9, FR-33, -/// FR-34). Each test uses its own named pasteboard. +/// Pasting formatted text and images. Each test uses its own named +/// pasteboard. @MainActor @Suite struct EditorPasteTests { func editor(_ text: String, selection: NSRange? = nil) -> EditorTextView { let (_, textView) = EditorTextView.makeScrollableEditor() @@ -523,7 +524,7 @@ extension EditorCodeBlockTests { } /// Services and drops from other apps read through readSelection, as - /// Paste does (FR-8); Paste and Match Style reads plain text (FR-4). + /// Paste does; Paste and Match Style reads plain text. @Test func readSelectionConverts() { let types: [NSPasteboard.PasteboardType: String] = [.html: "x", .string: "x"] var editor = editor("") @@ -547,7 +548,7 @@ extension EditorCodeBlockTests { } /// Formatted text dropped from another app is converted where it's - /// dropped (FR-8). + /// dropped. @Test func dropsConvert() { let (scrollView, textView) = EditorTextView.makeScrollableEditor() let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 400, height: 300), @@ -565,8 +566,7 @@ extension EditorCodeBlockTests { #expect(editor.string == "**x**first line\nsecond line") } - /// After a converted paste, a button offers the plain text instead - /// (FR-31). + /// After a converted paste, a button offers the plain text instead. @Test func plainTextButton() throws { let editor = editor("Intro\n\n") #expect(paste([.html: "

    bold text

    ", .string: "bold text"], into: editor)) @@ -620,8 +620,7 @@ extension EditorCodeBlockTests { return editor } - /// Typing dismisses the button, and the keystroke goes into the text - /// (FR-32). + /// Typing dismisses the button, and the keystroke goes into the text. @Test func typingDismissesThePlainTextButton() throws { let editor = try editorWithPlainTextButton() editor.insertText("!", replacementRange: editor.selectedRange()) @@ -689,7 +688,7 @@ extension EditorCodeBlockTests { #expect(editor.string == "Intro __bold**") } - /// Paste as Markdown converts with the setting off (FR-28). + /// Paste as Markdown converts with the setting off. @Test func pasteAsMarkdownIgnoresTheSetting() { let editor = editor("") editor.convertsPastedFormatting = false @@ -700,7 +699,7 @@ extension EditorCodeBlockTests { #expect(editor.responds(to: #selector(EditorTextView.pasteAsMarkdown(_:)))) } - /// Image data is pasted as a data URI, whatever the setting (FR-34). + /// Image data is pasted as a data URI, whatever the setting. @Test func images() { for converts in [true, false] { let editor = editor("See ") diff --git a/Tests/MacDownKitTests/EngineHighlightingTests.swift b/Tests/MacDownKitTests/EngineHighlightingTests.swift index a4c07b0..e1f350f 100644 --- a/Tests/MacDownKitTests/EngineHighlightingTests.swift +++ b/Tests/MacDownKitTests/EngineHighlightingTests.swift @@ -2,8 +2,8 @@ // EngineHighlightingTests.swift // MacDownKitTests // -// With the swift-markdown engine, the editor is highlighted from the -// renderer's document model instead of its own PEG parse (FR-1, FR-26). +// The editor is highlighted from the renderer's document model, the same +// cmark-gfm parse as the preview. // import AppKit @@ -42,21 +42,13 @@ extension LiveDocumentTests { effectiveRange: nil) as? NSColor } - /// `#Not a header` isn't one in CommonMark, but PEG colored it; both - /// color a real header. - @Test(arguments: [MarkdownEngine.hoedown, .cmarkGfm]) - func highlightsFromTheEngine(_ engine: MarkdownEngine) async { - let preferences = Preferences.shared - let saved = preferences.markdownEngine - preferences.markdownEngine = engine - defer { preferences.markdownEngine = saved } - + /// A real header is colored; `#Not a header` isn't one in CommonMark + /// (PEG Markdown Highlight colored it). + @Test func highlightsFromTheModel() async { let (controller, window) = makeController("Plain text.\n\n## Real\n\n#Not a header\n") defer { controller.tearDown(); window.close() } - #expect(controller.highlighter.usesExternalElements == (engine == .cmarkGfm)) #expect(await waitUntil { color(controller, at: "Real") != color(controller, at: "Plain") }) - let notHeader = color(controller, at: "Not a header") != color(controller, at: "Plain") - #expect(notHeader == (engine == .hoedown)) + #expect(color(controller, at: "Not a header") == color(controller, at: "Plain")) } /// Edits re-highlight from the new model, also with the preview's @@ -64,10 +56,9 @@ extension LiveDocumentTests { @Test(arguments: [false, true]) func editsRehighlight(manualRender: Bool) async { let preferences = Preferences.shared - let saved = (preferences.markdownEngine, preferences.markdownManualRender) - preferences.markdownEngine = .cmarkGfm + let saved = preferences.markdownManualRender preferences.markdownManualRender = manualRender - defer { (preferences.markdownEngine, preferences.markdownManualRender) = saved } + defer { preferences.markdownManualRender = saved } let (controller, window) = makeController("Plain text.\n") defer { controller.tearDown(); window.close() } @@ -82,15 +73,10 @@ extension LiveDocumentTests { } extension LiveDocumentTests { -/// With the new engine the preview carries data-source-line; HTML and PDF -/// exports don't (FR-18). +/// The preview carries data-source-line; HTML and PDF exports don't. @MainActor @Suite(.serialized) struct EngineExportTests { @Test func exportsHaveNoSourceLines() async throws { let preferences = Preferences.shared - let saved = preferences.markdownEngine - preferences.markdownEngine = .cmarkGfm - defer { preferences.markdownEngine = saved } - let controller = DocumentController(document: MarkdownDocument(text: "# Title\n\nSome text.\n"), fileURL: nil) let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 800, height: 600), diff --git a/Tests/MacDownKitTests/EngineSnapshots.swift b/Tests/MacDownKitTests/EngineSnapshots.swift new file mode 100644 index 0000000..c054bb7 --- /dev/null +++ b/Tests/MacDownKitTests/EngineSnapshots.swift @@ -0,0 +1,60 @@ +// +// EngineSnapshots.swift +// MacDownKitTests +// +// What the original engines produced, recorded on 2026-10-22 just before +// they were removed: hoedown's HTML (with MacDown's patches) and escaping, +// and PEG Markdown Highlight's style parser (pmh_styleparser.c). The port +// matched them byte for byte, and the tests keep it that way against these +// recordings (Resources/engine-snapshots.json). +// + +import Foundation +import Testing +@testable import MacDownKit + +enum EngineSnapshots { + static let values: [String: String] = { + let url = Bundle.module.url(forResource: "engine-snapshots", withExtension: "json", + subdirectory: "Resources")! + return try! JSONDecoder().decode([String: String].self, from: Data(contentsOf: url)) + }() + + /// The recording named `key`. + static func value(_ key: String) throws -> String { + try #require(values[key], "no snapshot \(key.debugDescription)") + } +} + +/// A theme parse result as text, one attribute per line, to compare with +/// the recorded C parser's. +func themeDescription(_ style: ThemeStyle) -> String { + func color(_ c: ThemeStyle.Color) -> String { + String(format: "%02x%02x%02x%02x", c.alpha, c.red, c.green, c.blue) + } + func describe(_ attribute: ThemeStyle.Attribute) -> String { + let value = switch attribute.value { + case .foregroundColor(let c): "foreground \(color(c))" + case .backgroundColor(let c): "background \(color(c))" + case .caretColor(let c): "caret \(color(c))" + case .fontSize(let points, let relative): "size \(points) relative \(relative)" + case .fontFamily(let family): "family \(family)" + case .fontStyle(let italic, let bold, let underlined): + "style italic \(italic) bold \(bold) underlined \(underlined)" + case .other(let string): "other \(string)" + } + return " \(attribute.name): \(value)" + } + var lines: [String] = [] + for (name, attributes) in [("editor", style.editor), ("editor-current-line", style.currentLine), + ("editor-selection", style.selection)] { + lines.append(name) + lines += attributes.map(describe) + } + for element in style.elements { + lines.append(element.element) + lines += element.attributes.map(describe) + } + lines += style.errors.map { "error \($0)" } + return lines.joined(separator: "\n") +} diff --git a/Tests/MacDownKitTests/HTMLDiff.swift b/Tests/MacDownKitTests/HTMLDiff.swift new file mode 100644 index 0000000..ad71afa --- /dev/null +++ b/Tests/MacDownKitTests/HTMLDiff.swift @@ -0,0 +1,209 @@ +// +// HTMLDiff.swift +// MacDownKitTests +// +// Comparing HTML: normalized so insignificant differences (attribute +// order, whitespace between tags, entities) don't count, and split into +// the runs that differ. Used by the paste round trip and the renderer +// tests. +// + +import Foundation +import Testing +@testable import MacDownKit + +enum HTMLDiff { + /// HTML with insignificant differences removed: attributes sorted within + /// each tag, whitespace between tags dropped, other runs collapsed. + static func normalize(_ html: String) -> String { + normalizeTags(decodeEntities(html)) + } + + /// Entities decoded to characters, so `©` (hoedown passes it + /// through) and `©` (cmark decodes it) compare equal. `< > & + /// "` stay: decoding them would change the markup. + static func decodeEntities(_ html: String) -> String { + guard html.contains("&") else { return html } + var result = "" + var rest = Substring(html) + while let amp = rest.firstIndex(of: "&") { + result += rest[.. String? { + if name.hasPrefix("#x") || name.hasPrefix("#X") { + return UInt32(name.dropFirst(2), radix: 16).flatMap(Unicode.Scalar.init).map { String($0) } + } + if name.hasPrefix("#") { + return UInt32(name.dropFirst()).flatMap(Unicode.Scalar.init).map { String($0) } + } + let named = ["nbsp": "\u{A0}", "copy": "©", "reg": "®", "trade": "™", "hellip": "…", + "mdash": "—", "ndash": "–", "ldquo": "“", "rdquo": "”", "lsquo": "‘", + "rsquo": "’", "laquo": "«", "raquo": "»", "middot": "·", "times": "×", + "deg": "°", "euro": "€", "pound": "£", "yen": "¥", "sect": "§", + "para": "¶", "bull": "•", "apos": "'", "rarr": "→", "larr": "←", + "uarr": "↑", "darr": "↓", "harr": "↔", "rArr": "⇒", "lArr": "⇐", + "check": "✓", "minus": "−", "plusmn": "±", "frac12": "½"] + return named[name] + } + + static func normalizeTags(_ html: String) -> String { + var output = String.UnicodeScalarView() + var text = String.UnicodeScalarView() // since the last tag + var hasContent = false + func flushText() { + // Whitespace alone between two tags is dropped. + if hasContent { output.append(contentsOf: text) } + text.removeAll(keepingCapacity: true) + hasContent = false + } + var scalars = html.unicodeScalars[...] + while let scalar = scalars.first { + if scalar == "<", let close = scalars.firstIndex(of: ">") { + let tag = normalizeTag(String(String.UnicodeScalarView(scalars[...close]))) + if blockClosers.contains(tag), text.last == " " { text.removeLast() } + flushText() + output.append(contentsOf: tag.unicodeScalars) + scalars = scalars[scalars.index(after: close)...] + continue + } + scalars = scalars.dropFirst() + if scalar.properties.isWhitespace { + if text.last != " " { text.append(" ") } // collapse runs + } else { + text.append(scalar) + hasContent = true + } + } + flushText() + return String(output).trimmingCharacters(in: .whitespaces) + } + + /// Closing tags of blocks, before which whitespace doesn't show. + private static let blockClosers: Set = [ + "

    ", "
  • ", "", "", "", "", "", "", + "", "", "", + ] + + /// `` → ``. Comments, doctypes and + /// closing tags are kept as they are. + private static func normalizeTag(_ tag: String) -> String { + var chars = Array(tag.unicodeScalars) + guard chars.count > 2, chars[1].properties.isAlphabetic else { return tag } + let selfClosing = tag.hasSuffix("/>") + chars.removeLast(selfClosing ? 2 : 1) + var index = 1 + func read(while condition: (Unicode.Scalar) -> Bool) -> String { + var result = String.UnicodeScalarView() + while index < chars.count, condition(chars[index]) { + result.append(chars[index]); index += 1 + } + return String(result) + } + func isSpace(_ c: Unicode.Scalar) -> Bool { c.properties.isWhitespace } + let name = read { !isSpace($0) && $0 != "/" } + var attributes: [String] = [] + while true { + _ = read { isSpace($0) || $0 == "/" } + guard index < chars.count else { break } + let key = read { !isSpace($0) && $0 != "=" && $0 != "/" } + _ = read(while: isSpace) + guard index < chars.count, chars[index] == "=" else { + attributes.append(key); continue + } + index += 1 + _ = read(while: isSpace) + var value: String + if index < chars.count, chars[index] == "\"" || chars[index] == "'" { + let quote = chars[index]; index += 1 + value = read { $0 != quote } + index += 1 + } else { + value = read { !isSpace($0) } + } + value = value.split(whereSeparator: \.isWhitespace).joined(separator: " ") + attributes.append("\(key)=\"\(value)\"") + } + return "<" + ([name] + attributes.sorted()).joined(separator: " ") + + (selfClosing ? " />" : ">") + } + + /// A run of differing tokens: what the left side has there, and what + /// the right one has. + struct Hunk: Sendable, Equatable { + let left: String + let right: String + } + + /// Tags and words (with their spacing) of normalized HTML. + static func tokens(_ html: String) -> [Substring] { + html.matches(of: /<[^>]*>|[^<\s]+|\s/).map(\.output) + } + + /// The differing token runs between two normalized HTML strings. + static func hunks(_ left: String, _ right: String) -> [Hunk] { + let a = tokens(left), b = tokens(right) + let difference = b.difference(from: a) + var removed = Set(), inserted = Set() + for change in difference { + switch change { + case .remove(let offset, _, _): removed.insert(offset) + case .insert(let offset, _, _): inserted.insert(offset) + } + } + // Tokens that aren't removed (left) or inserted (right) match in + // order, so walk both and collect each run of changes. + var hunks: [Hunk] = [] + var i = 0, j = 0 + while i < a.count || j < b.count { + if i < a.count && !removed.contains(i) && j < b.count && !inserted.contains(j) { + i += 1; j += 1; continue + } + var l = "", r = "" + while i < a.count && removed.contains(i) { l += a[i]; i += 1 } + while j < b.count && inserted.contains(j) { r += b[j]; j += 1 } + hunks.append(Hunk(left: l, right: r)) + } + return hunks + } +} + +@Suite struct HTMLDiffTests { + @Test func normalizerIgnoresAttributeOrderAndWhitespace() { + let a = #"

    Hi

    x"# + "\n
    \n text\n
    " + let b = #"

    Hi

    x"# + #"
    text
    "# + #expect(HTMLDiff.normalize(a) == HTMLDiff.normalize(b)) + #expect(HTMLDiff.normalize("") + == HTMLDiff.normalize("")) + // Real differences survive. + #expect(HTMLDiff.normalize("

    Hi

    ") != HTMLDiff.normalize("

    Hi!

    ")) + #expect(HTMLDiff.normalize(#""#) != HTMLDiff.normalize(#""#)) + #expect(HTMLDiff.normalize("x") != HTMLDiff.normalize("x")) + } + + @Test func hunksAreTheDifferingRuns() { + let hunks = HTMLDiff.hunks("

    one two three

    four

    ", + "

    one 2 three

    four five

    ") + #expect(hunks == [HTMLDiff.Hunk(left: "two", right: "2"), + HTMLDiff.Hunk(left: "", right: " five")]) + } + + @Test func entitiesDecodeForComparison() { + #expect(HTMLDiff.normalize("

    © © © ©

    ") == "

    © © © ©

    ") + #expect(HTMLDiff.normalize("

    <b> & "

    ") == "

    <b> & "

    ") + } +} diff --git a/Tests/MacDownKitTests/HTMLDiffHarness.swift b/Tests/MacDownKitTests/HTMLDiffHarness.swift deleted file mode 100644 index 9c77232..0000000 --- a/Tests/MacDownKitTests/HTMLDiffHarness.swift +++ /dev/null @@ -1,475 +0,0 @@ -// -// HTMLDiffHarness.swift -// MacDownKitTests -// -// Compares the body HTML of two Markdown engines over the corpus and a -// matrix of settings (TR-8). Today both sides are hoedown, which proves the -// harness; Phase 3 puts swift-markdown's HTMLRenderer on the right. -// -// Run: swift test --filter HTMLDiffHarnessTests -// Report: MACDOWN_DIFF_REPORT=/tmp/diff swift test --filter HTMLDiffHarnessTests -// writes html-diff.md there, one section per differing document. -// - -import Foundation -import Testing -@testable import MacDownKit - -enum HTMLDiff { - typealias Engine = @Sendable (String, ParseSettings) -> String - - static let hoedown: Engine = { MarkdownParser.parse($0, settings: $1).body } - - /// The cmark-gfm renderer, through the document model. - static let cmark: Engine = { text, settings in - MarkdownDocumentModel(text, options: .init(settings)).body - } - - /// The settings each document is rendered with: the always-on standard - /// set, each opt-in feature on its own, and everything on. - @MainActor static func matrix() -> [(name: String, settings: ParseSettings)] { - let optIns: [(String, (Preferences) -> Void)] = [ - ("highlight", { $0.extensionHighlight = true }), - ("superscript", { $0.extensionSuperscript = true }), - ("autolink", { $0.extensionAutolink = true }), - ("smart punctuation", { $0.extensionSmartyPants = true }), - ("math", { $0.htmlMathJax = true; $0.htmlMathJaxInlineDollar = true }), - ("toc", { $0.htmlRendersTOC = true }), - ("hard wrap", { $0.htmlHardWrap = true }), - ] - func settings(_ configure: (Preferences) -> Void) -> ParseSettings { - let suite = "MacDownDiffHarness-\(UUID().uuidString)" - let defaults = UserDefaults(suiteName: suite)! - defer { defaults.removePersistentDomain(forName: suite) } - let preferences = Preferences(defaults: defaults) - // Every opt-in off, whatever the fresh-install defaults are. - preferences.extensionHighlight = false - preferences.extensionSuperscript = false - preferences.extensionAutolink = false - preferences.extensionSmartyPants = false - preferences.htmlMathJax = false - preferences.htmlMathJaxInlineDollar = false - preferences.htmlRendersTOC = false - preferences.htmlHardWrap = false - configure(preferences) - return preferences.renderSettings.parse - } - return [("standard", settings { _ in })] - + optIns.map { name, configure in (name, settings(configure)) } - + [("all on", settings { p in optIns.forEach { $0.1(p) } })] - } - - /// HTML with insignificant differences removed: attributes sorted within - /// each tag, whitespace between tags dropped, other runs collapsed. - /// A single scan: this runs over every document in every setting. - static func normalize(_ html: String) -> String { - normalizeTags(decodeEntities(html)) - } - - /// Entities decoded to characters, so `©` (hoedown passes it - /// through) and `©` (cmark decodes it) compare equal. `< > & - /// "` stay: decoding them would change the markup. - static func decodeEntities(_ html: String) -> String { - guard html.contains("&") else { return html } - var result = "" - var rest = Substring(html) - while let amp = rest.firstIndex(of: "&") { - result += rest[.. String? { - if name.hasPrefix("#x") || name.hasPrefix("#X") { - return UInt32(name.dropFirst(2), radix: 16).flatMap(Unicode.Scalar.init).map { String($0) } - } - if name.hasPrefix("#") { - return UInt32(name.dropFirst()).flatMap(Unicode.Scalar.init).map { String($0) } - } - let named = ["nbsp": "\u{A0}", "copy": "©", "reg": "®", "trade": "™", "hellip": "…", - "mdash": "—", "ndash": "–", "ldquo": "“", "rdquo": "”", "lsquo": "‘", - "rsquo": "’", "laquo": "«", "raquo": "»", "middot": "·", "times": "×", - "deg": "°", "euro": "€", "pound": "£", "yen": "¥", "sect": "§", - "para": "¶", "bull": "•", "apos": "'", "rarr": "→", "larr": "←", - "uarr": "↑", "darr": "↓", "harr": "↔", "rArr": "⇒", "lArr": "⇐", - "check": "✓", "minus": "−", "plusmn": "±", "frac12": "½"] - return named[name] - } - - static func normalizeTags(_ html: String) -> String { - var output = String.UnicodeScalarView() - var text = String.UnicodeScalarView() // since the last tag - var hasContent = false - func flushText() { - // Whitespace alone between two tags is dropped. - if hasContent { output.append(contentsOf: text) } - text.removeAll(keepingCapacity: true) - hasContent = false - } - var scalars = html.unicodeScalars[...] - while let scalar = scalars.first { - if scalar == "<", let close = scalars.firstIndex(of: ">") { - let tag = normalizeTag(String(String.UnicodeScalarView(scalars[...close]))) - if blockClosers.contains(tag), text.last == " " { text.removeLast() } - flushText() - output.append(contentsOf: tag.unicodeScalars) - scalars = scalars[scalars.index(after: close)...] - continue - } - scalars = scalars.dropFirst() - if scalar.properties.isWhitespace { - if text.last != " " { text.append(" ") } // collapse runs - } else { - text.append(scalar) - hasContent = true - } - } - flushText() - return String(output).trimmingCharacters(in: .whitespaces) - } - - /// Closing tags of blocks, before which whitespace doesn't show. - private static let blockClosers: Set = [ - "

    ", "", "", "", "", "", "", "", - "", "", "", - ] - - /// `` → ``. Comments, doctypes and - /// closing tags are kept as they are. - private static func normalizeTag(_ tag: String) -> String { - var chars = Array(tag.unicodeScalars) - guard chars.count > 2, chars[1].properties.isAlphabetic else { return tag } - let selfClosing = tag.hasSuffix("/>") - chars.removeLast(selfClosing ? 2 : 1) - var index = 1 - func read(while condition: (Unicode.Scalar) -> Bool) -> String { - var result = String.UnicodeScalarView() - while index < chars.count, condition(chars[index]) { - result.append(chars[index]); index += 1 - } - return String(result) - } - func isSpace(_ c: Unicode.Scalar) -> Bool { c.properties.isWhitespace } - let name = read { !isSpace($0) && $0 != "/" } - var attributes: [String] = [] - while true { - _ = read { isSpace($0) || $0 == "/" } - guard index < chars.count else { break } - let key = read { !isSpace($0) && $0 != "=" && $0 != "/" } - _ = read(while: isSpace) - guard index < chars.count, chars[index] == "=" else { - attributes.append(key); continue - } - index += 1 - _ = read(while: isSpace) - var value: String - if index < chars.count, chars[index] == "\"" || chars[index] == "'" { - let quote = chars[index]; index += 1 - value = read { $0 != quote } - index += 1 - } else { - value = read { !isSpace($0) } - } - value = value.split(whereSeparator: \.isWhitespace).joined(separator: " ") - attributes.append("\(key)=\"\(value)\"") - } - return "<" + ([name] + attributes.sorted()).joined(separator: " ") - + (selfClosing ? " />" : ">") - } - - /// An intended difference between hoedown and the new engine, listed - /// once in Resources/expected-html-diffs.json rather than per document. - /// A hunk is expected when the entries' `find` → `replace` rewrites, - /// applied in turn, make hoedown's side into the other side (neighboring - /// differences can share a hunk). - struct ExpectedDifference: Decodable, Sendable { - let id: String - let reason: String - let find: String - let replace: String - - func rewrite(_ html: String) -> String { - guard let regex = try? NSRegularExpression(pattern: find) else { return html } - return regex.stringByReplacingMatches( - in: html, range: NSRange(location: 0, length: (html as NSString).length), - withTemplate: replace) - } - } - - /// The ids of the entries that explain a hunk, or nil if they don't. - static func explanation(of hunk: Hunk, by entries: [ExpectedDifference]) -> [String]? { - var html = hunk.left - var ids: [String] = [] - for entry in entries { - let rewritten = entry.rewrite(html) - if rewritten != html { ids.append(entry.id); html = rewritten } - } - return !ids.isEmpty && html == hunk.right ? ids : nil - } - - static func expectedDifferences() throws -> [ExpectedDifference] { - let url = Bundle.module.url(forResource: "expected-html-diffs", withExtension: "json", - subdirectory: "Resources")! - return try JSONDecoder().decode([ExpectedDifference].self, from: Data(contentsOf: url)) - } - - /// A run of differing tokens: what the left engine has there, and what - /// the right one has. - struct Hunk: Sendable, Equatable { - let left: String - let right: String - } - - /// Tags and words (with their spacing) of normalized HTML. - static func tokens(_ html: String) -> [Substring] { - html.matches(of: /<[^>]*>|[^<\s]+|\s/).map(\.output) - } - - /// The differing token runs between two normalized HTML strings. - static func hunks(_ left: String, _ right: String) -> [Hunk] { - let a = tokens(left), b = tokens(right) - let difference = b.difference(from: a) - var removed = Set(), inserted = Set() - for change in difference { - switch change { - case .remove(let offset, _, _): removed.insert(offset) - case .insert(let offset, _, _): inserted.insert(offset) - } - } - // Tokens that aren't removed (left) or inserted (right) match in - // order, so walk both and collect each run of changes. - var hunks: [Hunk] = [] - var i = 0, j = 0 - while i < a.count || j < b.count { - if i < a.count && !removed.contains(i) && j < b.count && !inserted.contains(j) { - i += 1; j += 1; continue - } - var l = "", r = "" - while i < a.count && removed.contains(i) { l += a[i]; i += 1 } - while j < b.count && inserted.contains(j) { r += b[j]; j += 1 } - hunks.append(Hunk(left: l, right: r)) - } - return hunks - } - - struct Difference: Sendable { - let document: String - let setting: String - /// Hunks no expected difference explains. - let hunks: [Hunk] - } - - struct Comparison: Sendable { - var differences: [Difference] = [] - /// How often each expected difference occurred. - var expected: [String: Int] = [:] - } - - /// Renders every document with every setting on both engines, and - /// returns the differences the expected list doesn't explain. - @MainActor static func compare(_ documents: [Corpus.Document], left: Engine, right: Engine, - expected: [ExpectedDifference] = []) -> Comparison { - var comparison = Comparison() - for (name, settings) in matrix() { - for document in documents { - let l = normalize(left(document.text, settings)) - let r = normalize(right(document.text, settings)) - guard l != r else { continue } - var unexplained: [Hunk] = [] - for hunk in hunks(l, r) { - if let ids = explanation(of: hunk, by: expected) { - for id in ids { comparison.expected[id, default: 0] += 1 } - } else { - unexplained.append(hunk) - } - } - if !unexplained.isEmpty { - comparison.differences.append(Difference( - document: document.name, setting: name, hunks: unexplained)) - } - } - } - return comparison - } - - /// A Markdown report, written to $MACDOWN_DIFF_REPORT if it's set. - static func report(_ comparison: Comparison, expected: [ExpectedDifference] = [], - left: String, right: String, - documents: Int, settings: Int, writes: Bool = true) -> String { - let differences = comparison.differences - var lines = ["# HTML diff: \(left) vs \(right)", "", - "\(documents) documents × \(settings) settings: \(differences.count) with unexpected differences.", ""] - if !expected.isEmpty { - lines += ["## Expected differences", ""] - lines += expected.map { "- **\($0.id)** (\(comparison.expected[$0.id] ?? 0)×): \($0.reason)" } - lines.append("") - } - for difference in differences { - lines += ["## \(difference.document) (\(difference.setting))", ""] - for hunk in difference.hunks.prefix(20) { - lines += ["- \(left): `\(hunk.left.prefix(200))`", " \(right): `\(hunk.right.prefix(200))`"] - } - lines.append("") - } - let text = lines.joined(separator: "\n") - if writes, let directory = ProcessInfo.processInfo.environment["MACDOWN_DIFF_REPORT"] { - let url = URL(fileURLWithPath: directory, isDirectory: true) - try? FileManager.default.createDirectory(at: url, withIntermediateDirectories: true) - try? text.write(to: url.appending(path: "html-diff.md"), atomically: true, encoding: .utf8) - } - return text - } -} - -// Inside the serialized live group: the harness renders the corpus many -// times, and run alongside the WKWebView suites it starves their timeouts. -extension LiveDocumentTests { -@MainActor @Suite struct HTMLDiffHarnessTests { - @Test func normalizerIgnoresAttributeOrderAndWhitespace() { - let a = #"

    Hi

    x"# + "\n
    \n text\n
    " - let b = #"

    Hi

    x"# + #"
    text
    "# - #expect(HTMLDiff.normalize(a) == HTMLDiff.normalize(b)) - #expect(HTMLDiff.normalize("") - == HTMLDiff.normalize("")) - // Real differences survive. - #expect(HTMLDiff.normalize("

    Hi

    ") != HTMLDiff.normalize("

    Hi!

    ")) - #expect(HTMLDiff.normalize(#"
    "#) != HTMLDiff.normalize(#""#)) - #expect(HTMLDiff.normalize("x") != HTMLDiff.normalize("x")) - } - - @Test func matrixCoversEveryOptIn() { - let matrix = HTMLDiff.matrix() - #expect(matrix.map(\.name) == ["standard", "highlight", "superscript", "autolink", - "smart punctuation", "math", "toc", "hard wrap", "all on"]) - // Each setting renders differently from the standard set somewhere. - let corpus = (try? Corpus.all()) ?? [] - let standard = matrix[0].settings - for (name, settings) in matrix.dropFirst() { - let changes = corpus.contains { - HTMLDiff.hoedown($0.text, settings) != HTMLDiff.hoedown($0.text, standard) - } - #expect(changes, "\(name) changes nothing") - } - } - - /// Proves the harness end to end: an engine against itself has no - /// differences, and a deliberately different engine is reported. - @Test func hoedownAgainstItself() throws { - let corpus = try Corpus.all() - let expected = try HTMLDiff.expectedDifferences() - let comparison = HTMLDiff.compare(corpus, left: HTMLDiff.hoedown, - right: HTMLDiff.hoedown, expected: expected) - let report = HTMLDiff.report(comparison, expected: expected, left: "hoedown", - right: "hoedown", documents: corpus.count, - settings: HTMLDiff.matrix().count) - #expect(comparison.differences.isEmpty && comparison.expected.isEmpty, "\(report)") - - let files = try Corpus.files() - let altered: HTMLDiff.Engine = { - HTMLDiff.hoedown($0, $1).replacingOccurrences(of: "", with: "") - } - let caught = HTMLDiff.compare(files, left: HTMLDiff.hoedown, right: altered) - #expect(caught.differences.contains { $0.document == "01-inline.md" && $0.setting == "standard" }) - #expect(HTMLDiff.report(caught, left: "hoedown", right: "altered", - documents: files.count, settings: 9, writes: false) - .contains("## 01-inline.md (standard)")) - } - - @Test func hunksAreTheDifferingRuns() { - let hunks = HTMLDiff.hunks("

    one two three

    four

    ", - "

    one 2 three

    four five

    ") - #expect(hunks == [HTMLDiff.Hunk(left: "two", right: "2"), - HTMLDiff.Hunk(left: "", right: " five")]) - } - - /// An engine that leaves intra-word underscores alone, as CommonMark - /// does, differs from hoedown only by expected differences, each listed - /// once with its count. - @Test func expectedDifferencesAreListedOnce() throws { - let expected = try HTMLDiff.expectedDifferences() - #expect(Set(expected.map(\.id)).count == expected.count) - let commonMark: HTMLDiff.Engine = { text, settings in - HTMLDiff.hoedown(text, settings) - .replacing(/snakecase<\/em>name/, with: "snake_case_name") - .replacing(/foobar<\/strong>baz/, with: "foo__bar__baz") - } - let files = try Corpus.files() - let comparison = HTMLDiff.compare(files, left: HTMLDiff.hoedown, right: commonMark, - expected: expected) - #expect(comparison.differences.isEmpty) - #expect(comparison.expected["intraword-underscore-emphasis", default: 0] > 0) - #expect(comparison.expected["intraword-underscore-strong", default: 0] > 0) - let report = HTMLDiff.report(comparison, expected: expected, left: "hoedown", - right: "CommonMark", documents: files.count, - settings: 9, writes: false) - #expect(report.contains("0 with unexpected differences")) - #expect(report.components(separatedBy: "intraword-underscore-emphasis").count == 2) - // Without the list, the same differences are unexpected. - #expect(!HTMLDiff.compare(files, left: HTMLDiff.hoedown, right: commonMark) - .differences.isEmpty) - } - - /// A difference between hoedown and cmark-gfm that was reviewed and is - /// intended (Phase 3 review, 2026-10-09). - struct Reviewed: Decodable { - let document: String - let hoedown: String - let cmark: String - let reason: String - } - - /// hoedown against the cmark-gfm renderer over the corpus and every - /// setting. Each remaining difference is reviewed, with its reason, in - /// Resources/reviewed-html-diffs.json (and summarized in - /// docs/MACDOWN-PORT.md); a new one fails, and so does one that's gone. - @Test func hoedownAgainstCmarkReviewed() throws { - let corpus = try Corpus.all() - let expected = try HTMLDiff.expectedDifferences() - let comparison = HTMLDiff.compare(corpus, left: HTMLDiff.hoedown, right: HTMLDiff.cmark, - expected: expected) - let report = HTMLDiff.report(comparison, expected: expected, left: "hoedown", - right: "cmark", documents: corpus.count, - settings: HTMLDiff.matrix().count, writes: false) - if let directory = ProcessInfo.processInfo.environment["MACDOWN_DIFF_REPORT"] { - let url = URL(fileURLWithPath: directory, isDirectory: true) - try? FileManager.default.createDirectory(at: url, withIntermediateDirectories: true) - try report.write(to: url.appending(path: "html-diff-cmark.md"), atomically: true, encoding: .utf8) - } - let url = Bundle.module.url(forResource: "reviewed-html-diffs", withExtension: "json", - subdirectory: "Resources")! - let reviewed = try JSONDecoder().decode([Reviewed].self, from: Data(contentsOf: url)) - func key(_ document: String, _ hoedown: String, _ cmark: String) -> String { - document + "\u{1}" + hoedown + "\u{1}" + cmark - } - let reviewedKeys = Set(reviewed.map { key($0.document, $0.hoedown, $0.cmark) }) - var found = Set() - for difference in comparison.differences { - for hunk in difference.hunks { - let k = key(difference.document, hunk.left, hunk.right) - found.insert(k) - #expect(reviewedKeys.contains(k), - "unreviewed: \(difference.document) (\(difference.setting)) hoedown \(hunk.left.debugDescription) cmark \(hunk.right.debugDescription)") - } - } - #expect(reviewedKeys.subtracting(found).isEmpty, "reviewed differences that are gone; remove them") - #expect(reviewed.allSatisfy { !$0.reason.isEmpty }) - } - - @Test func entitiesDecodeForComparison() { - #expect(HTMLDiff.normalize("

    © © © ©

    ") == "

    © © © ©

    ") - #expect(HTMLDiff.normalize("

    <b> & "

    ") == "

    <b> & "

    ") - } -} -} diff --git a/Tests/MacDownKitTests/HTMLRendererTests.swift b/Tests/MacDownKitTests/HTMLRendererTests.swift index 11b36c3..5055e52 100644 --- a/Tests/MacDownKitTests/HTMLRendererTests.swift +++ b/Tests/MacDownKitTests/HTMLRendererTests.swift @@ -2,10 +2,10 @@ // HTMLRendererTests.swift // MacDownKitTests // -// The cmark-gfm renderer writes hoedown's markup (TR-5). +// The cmark-gfm renderer writes hoedown's markup, checked against +// hoedown's recorded output (EngineSnapshots). // -import CHoedown import Foundation import Testing @testable import MacDownKit @@ -13,23 +13,15 @@ import Testing @Suite struct HTMLEscapingTests { static let stress = #"a & b < c > d "e" 'f' /g/ \h [i] {j} |k| ~l `m` ^n é 😀 %20 ?x=1&y='2' #frag"# - func hoedown(_ text: String, _ escape: (UnsafeMutablePointer?, UnsafePointer, Int) -> Void) -> String { - let ob = hoedown_buffer_new(64) - defer { hoedown_buffer_free(ob) } - let bytes = Array(text.utf8) - bytes.withUnsafeBufferPointer { escape(ob, $0.baseAddress!, $0.count) } - return String(decoding: UnsafeBufferPointer(start: ob!.pointee.data, count: ob!.pointee.size), as: UTF8.self) + @Test func htmlMatchesHoedown() throws { + #expect(HTMLEscaping.html(Self.stress) == (try EngineSnapshots.value("escape/html"))) } - @Test func htmlMatchesHoedown() { - #expect(HTMLEscaping.html(Self.stress) == hoedown(Self.stress) { hoedown_escape_html($0, $1, $2, 0) }) - } - - @Test func hrefMatchesHoedown() { - #expect(HTMLEscaping.href(Self.stress) == hoedown(Self.stress) { hoedown_escape_href($0, $1, $2) }) + @Test func hrefMatchesHoedown() throws { + #expect(HTMLEscaping.href(Self.stress) == (try EngineSnapshots.value("escape/href"))) // Every byte value. let all = String(decoding: (1...127).map { UInt8($0) }, as: UTF8.self) - #expect(HTMLEscaping.href(all) == hoedown(all) { hoedown_escape_href($0, $1, $2) }) + #expect(HTMLEscaping.href(all) == (try EngineSnapshots.value("escape/href-ascii"))) } } @@ -38,14 +30,9 @@ import Testing MarkdownDocumentModel(text, options: options).body } - /// hoedown's output with fresh-install settings. - func hoedown(_ text: String) -> String { - MarkdownParser.parse(text, settings: CorpusTests.settings).body - } - /// Where CommonMark and hoedown agree, the output is hoedown's, byte - /// for byte (TR-5). - @Test(arguments: [ + /// for byte. + nonisolated static let byteForByte = [ "# One\n\nText *em* **strong** `code`.\n\n## Two\n", "- a\n- b\n", "- a\n\n- b\n", @@ -61,17 +48,36 @@ import Testing "A[^n] B[^m].\n\n[^m]: Em.\n\n[^n]: En.\n", "[a](https://x.org/?a=1&b='2' \"T\") ![alt](i.png \"t\") s\n", "
    \nraw\n
    \n\n---\n", - ]) - func matchesHoedown(_ text: String) { - #expect(html(text) == hoedown(text)) + ] + + static let tocTexts = { () throws -> [String] in + [try #require(try Corpus.files().first { $0.name == "13-toc.md" }).text, + "## Start\n\n[TOC]\n\n# Higher [link](x) *em*\n\n### Deep\n"] + } + + static let mathTexts = [ + "$$\n\\int_0^1 x^2 \\, dx < 1\n$$\n", + "Inline \\\\( a_1 * b_2 \\\\) and display \\\\[ c_{*} \\\\].\n", + "In text $$x_1 * y_2$$ here.\n", + "Dollars $A^T_S = B$ and *emphasis*.\n", + "# Header $$h_1$$\n\n| $t_1$ |\n|---|\n", + ] + + static let autolinkText = "See https://example.org/page?q=1, www.example.org and hello@example.org; .\n" + static let smartText = "\"Double,\" 'single,' it's, en -- dash, em --- dash... `\"code\" --`\n\n```\n\"block\" --\n```\n" + static let markText = "==marked== and == spaced == and x^2, 10^(-6), e^(i pi) and a ^ caret. `==no== x^2`\n" + + @Test(arguments: byteForByte) + func matchesHoedown(_ text: String) throws { + #expect(html(text) == (try EngineSnapshots.value("render/" + text))) } - /// Front matter (FR-15): a valid YAML block is a table before the body; + /// Front matter: a valid YAML block is a table before the body; /// otherwise it's Markdown. Same as hoedown. @Test(arguments: ["09-front-matter.md", "11-leading-rule.md"]) func frontMatter(_ name: String) throws { let text = try #require(try Corpus.files().first { $0.name == name }).text - #expect(HTMLDiff.normalize(html(text)) == HTMLDiff.normalize(hoedown(text))) + #expect(HTMLDiff.normalize(html(text)) == HTMLDiff.normalize(try EngineSnapshots.value("front-matter/" + name))) } /// Invalid front matter is Markdown; in CommonMark a setext header can @@ -83,27 +89,26 @@ import Testing #expect(body.hasPrefix("
    \n\n

    title: "unterminated\ntags: [one, two

    ")) } - /// [TOC] (FR-12) with the setting on: hoedown's nested lists, the + /// [TOC] with the setting on: hoedown's nested lists, the /// outer one classed "toc", linking to the toc_N header ids. @Test func tableOfContents() throws { var settings = CorpusTests.settings settings.rendersTOC = true - for text in [try #require(try Corpus.files().first { $0.name == "13-toc.md" }).text, - "## Start\n\n[TOC]\n\n# Higher [link](x) *em*\n\n### Deep\n"] { + for (index, text) in try Self.tocTexts().enumerated() { let cmark = MarkdownDocumentModel(text, options: .init(settings)).body #expect(cmark.contains("