pandoc-crossref 0.2.7.0 → 0.3.0.0
raw patch · 40 files changed
+1947/−885 lines, 40 filesdep +deepseqdep +open-browserdep +optparse-applicativedep ~pandocPVP ok
version bump matches the API change (PVP)
Dependencies added: deepseq, open-browser, optparse-applicative, temporary
Dependency ranges changed: pandoc
API changes (from Hackage documentation)
+ Text.Pandoc.CrossRef: defaultMeta :: Meta
Files
- LICENSE +339/−0
- LICENSE.md +0/−339
- demo.md +0/−129
- docs/demo/demo.md +133/−0
- docs/index.md +523/−0
- lib/Text/Pandoc/CrossRef.hs +21/−0
- lib/Text/Pandoc/CrossRef/References.hs +20/−0
- lib/Text/Pandoc/CrossRef/References/Blocks.hs +46/−24
- lib/Text/Pandoc/CrossRef/References/List.hs +23/−3
- lib/Text/Pandoc/CrossRef/References/Refs.hs +42/−24
- lib/Text/Pandoc/CrossRef/References/Types.hs +20/−0
- lib/Text/Pandoc/CrossRef/Util/CodeBlockCaptions.hs +22/−3
- lib/Text/Pandoc/CrossRef/Util/CustomLabels.hs +27/−8
- lib/Text/Pandoc/CrossRef/Util/Gap.hs +0/−6
- lib/Text/Pandoc/CrossRef/Util/Meta.hs +80/−35
- lib/Text/Pandoc/CrossRef/Util/ModifyMeta.hs +49/−27
- lib/Text/Pandoc/CrossRef/Util/Options.hs +20/−0
- lib/Text/Pandoc/CrossRef/Util/PandocOrphans.hs +20/−0
- lib/Text/Pandoc/CrossRef/Util/Settings.hs +25/−3
- lib/Text/Pandoc/CrossRef/Util/Settings/Gen.hs +20/−0
- lib/Text/Pandoc/CrossRef/Util/Settings/Template.hs +21/−1
- lib/Text/Pandoc/CrossRef/Util/Template.hs +29/−9
- lib/Text/Pandoc/CrossRef/Util/Util.hs +30/−3
- pandoc-crossref.cabal +67/−58
- src/ManData.hs +70/−0
- src/pandoc-crossref.hs +64/−2
- test/Native.hs +20/−0
- test/demo-chapters.inc +16/−16
- test/demo.inc +6/−6
- test/m2m/equations-auto/expect.md +5/−5
- test/m2m/equations-tables-auto/expect.md +32/−40
- test/m2m/equations-tables/expect.md +20/−28
- test/m2m/listing-captions-ids/expect.md +16/−32
- test/m2m/listing-captions-ids/expect.tex +17/−8
- test/m2m/subfigures-ccsDelim/expect.md +8/−12
- test/m2m/subfigures-grid/expect.md +8/−12
- test/m2m/subfigures-grid/expect.tex +9/−9
- test/m2m/subfigures/expect.md +8/−12
- test/test-integrative.hs +34/−10
- test/test-pandoc-crossref.hs +37/−21
+ LICENSE view
@@ -0,0 +1,339 @@+GNU GENERAL PUBLIC LICENSE+ Version 2, June 1991++ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA+ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.++ Preamble++ The licenses for most software are designed to take away your+freedom to share and change it. By contrast, the GNU General Public+License is intended to guarantee your freedom to share and change free+software--to make sure the software is free for all its users. This+General Public License applies to most of the Free Software+Foundation's software and to any other program whose authors commit to+using it. (Some other Free Software Foundation software is covered by+the GNU Lesser General Public License instead.) You can apply it to+your programs, too.++ When we speak of free software, we are referring to freedom, not+price. Our General Public Licenses are designed to make sure that you+have the freedom to distribute copies of free software (and charge for+this service if you wish), that you receive source code or can get it+if you want it, that you can change the software or use pieces of it+in new free programs; and that you know you can do these things.++ To protect your rights, we need to make restrictions that forbid+anyone to deny you these rights or to ask you to surrender the rights.+These restrictions translate to certain responsibilities for you if you+distribute copies of the software, or if you modify it.++ For example, if you distribute copies of such a program, whether+gratis or for a fee, you must give the recipients all the rights that+you have. You must make sure that they, too, receive or can get the+source code. And you must show them these terms so they know their+rights.++ We protect your rights with two steps: (1) copyright the software, and+(2) offer you this license which gives you legal permission to copy,+distribute and/or modify the software.++ Also, for each author's protection and ours, we want to make certain+that everyone understands that there is no warranty for this free+software. If the software is modified by someone else and passed on, we+want its recipients to know that what they have is not the original, so+that any problems introduced by others will not reflect on the original+authors' reputations.++ Finally, any free program is threatened constantly by software+patents. We wish to avoid the danger that redistributors of a free+program will individually obtain patent licenses, in effect making the+program proprietary. To prevent this, we have made it clear that any+patent must be licensed for everyone's free use or not licensed at all.++ The precise terms and conditions for copying, distribution and+modification follow.++ GNU GENERAL PUBLIC LICENSE+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION++ 0. This License applies to any program or other work which contains+a notice placed by the copyright holder saying it may be distributed+under the terms of this General Public License. The "Program", below,+refers to any such program or work, and a "work based on the Program"+means either the Program or any derivative work under copyright law:+that is to say, a work containing the Program or a portion of it,+either verbatim or with modifications and/or translated into another+language. (Hereinafter, translation is included without limitation in+the term "modification".) Each licensee is addressed as "you".++Activities other than copying, distribution and modification are not+covered by this License; they are outside its scope. The act of+running the Program is not restricted, and the output from the Program+is covered only if its contents constitute a work based on the+Program (independent of having been made by running the Program).+Whether that is true depends on what the Program does.++ 1. You may copy and distribute verbatim copies of the Program's+source code as you receive it, in any medium, provided that you+conspicuously and appropriately publish on each copy an appropriate+copyright notice and disclaimer of warranty; keep intact all the+notices that refer to this License and to the absence of any warranty;+and give any other recipients of the Program a copy of this License+along with the Program.++You may charge a fee for the physical act of transferring a copy, and+you may at your option offer warranty protection in exchange for a fee.++ 2. You may modify your copy or copies of the Program or any portion+of it, thus forming a work based on the Program, and copy and+distribute such modifications or work under the terms of Section 1+above, provided that you also meet all of these conditions:++ a) You must cause the modified files to carry prominent notices+ stating that you changed the files and the date of any change.++ b) You must cause any work that you distribute or publish, that in+ whole or in part contains or is derived from the Program or any+ part thereof, to be licensed as a whole at no charge to all third+ parties under the terms of this License.++ c) If the modified program normally reads commands interactively+ when run, you must cause it, when started running for such+ interactive use in the most ordinary way, to print or display an+ announcement including an appropriate copyright notice and a+ notice that there is no warranty (or else, saying that you provide+ a warranty) and that users may redistribute the program under+ these conditions, and telling the user how to view a copy of this+ License. (Exception: if the Program itself is interactive but+ does not normally print such an announcement, your work based on+ the Program is not required to print an announcement.)++These requirements apply to the modified work as a whole. If+identifiable sections of that work are not derived from the Program,+and can be reasonably considered independent and separate works in+themselves, then this License, and its terms, do not apply to those+sections when you distribute them as separate works. But when you+distribute the same sections as part of a whole which is a work based+on the Program, the distribution of the whole must be on the terms of+this License, whose permissions for other licensees extend to the+entire whole, and thus to each and every part regardless of who wrote it.++Thus, it is not the intent of this section to claim rights or contest+your rights to work written entirely by you; rather, the intent is to+exercise the right to control the distribution of derivative or+collective works based on the Program.++In addition, mere aggregation of another work not based on the Program+with the Program (or with a work based on the Program) on a volume of+a storage or distribution medium does not bring the other work under+the scope of this License.++ 3. You may copy and distribute the Program (or a work based on it,+under Section 2) in object code or executable form under the terms of+Sections 1 and 2 above provided that you also do one of the following:++ a) Accompany it with the complete corresponding machine-readable+ source code, which must be distributed under the terms of Sections+ 1 and 2 above on a medium customarily used for software interchange; or,++ b) Accompany it with a written offer, valid for at least three+ years, to give any third party, for a charge no more than your+ cost of physically performing source distribution, a complete+ machine-readable copy of the corresponding source code, to be+ distributed under the terms of Sections 1 and 2 above on a medium+ customarily used for software interchange; or,++ c) Accompany it with the information you received as to the offer+ to distribute corresponding source code. (This alternative is+ allowed only for noncommercial distribution and only if you+ received the program in object code or executable form with such+ an offer, in accord with Subsection b above.)++The source code for a work means the preferred form of the work for+making modifications to it. For an executable work, complete source+code means all the source code for all modules it contains, plus any+associated interface definition files, plus the scripts used to+control compilation and installation of the executable. However, as a+special exception, the source code distributed need not include+anything that is normally distributed (in either source or binary+form) with the major components (compiler, kernel, and so on) of the+operating system on which the executable runs, unless that component+itself accompanies the executable.++If distribution of executable or object code is made by offering+access to copy from a designated place, then offering equivalent+access to copy the source code from the same place counts as+distribution of the source code, even though third parties are not+compelled to copy the source along with the object code.++ 4. You may not copy, modify, sublicense, or distribute the Program+except as expressly provided under this License. Any attempt+otherwise to copy, modify, sublicense or distribute the Program is+void, and will automatically terminate your rights under this License.+However, parties who have received copies, or rights, from you under+this License will not have their licenses terminated so long as such+parties remain in full compliance.++ 5. You are not required to accept this License, since you have not+signed it. However, nothing else grants you permission to modify or+distribute the Program or its derivative works. These actions are+prohibited by law if you do not accept this License. Therefore, by+modifying or distributing the Program (or any work based on the+Program), you indicate your acceptance of this License to do so, and+all its terms and conditions for copying, distributing or modifying+the Program or works based on it.++ 6. Each time you redistribute the Program (or any work based on the+Program), the recipient automatically receives a license from the+original licensor to copy, distribute or modify the Program subject to+these terms and conditions. You may not impose any further+restrictions on the recipients' exercise of the rights granted herein.+You are not responsible for enforcing compliance by third parties to+this License.++ 7. If, as a consequence of a court judgment or allegation of patent+infringement or for any other reason (not limited to patent issues),+conditions are imposed on you (whether by court order, agreement or+otherwise) that contradict the conditions of this License, they do not+excuse you from the conditions of this License. If you cannot+distribute so as to satisfy simultaneously your obligations under this+License and any other pertinent obligations, then as a consequence you+may not distribute the Program at all. For example, if a patent+license would not permit royalty-free redistribution of the Program by+all those who receive copies directly or indirectly through you, then+the only way you could satisfy both it and this License would be to+refrain entirely from distribution of the Program.++If any portion of this section is held invalid or unenforceable under+any particular circumstance, the balance of the section is intended to+apply and the section as a whole is intended to apply in other+circumstances.++It is not the purpose of this section to induce you to infringe any+patents or other property right claims or to contest validity of any+such claims; this section has the sole purpose of protecting the+integrity of the free software distribution system, which is+implemented by public license practices. Many people have made+generous contributions to the wide range of software distributed+through that system in reliance on consistent application of that+system; it is up to the author/donor to decide if he or she is willing+to distribute software through any other system and a licensee cannot+impose that choice.++This section is intended to make thoroughly clear what is believed to+be a consequence of the rest of this License.++ 8. If the distribution and/or use of the Program is restricted in+certain countries either by patents or by copyrighted interfaces, the+original copyright holder who places the Program under this License+may add an explicit geographical distribution limitation excluding+those countries, so that distribution is permitted only in or among+countries not thus excluded. In such case, this License incorporates+the limitation as if written in the body of this License.++ 9. The Free Software Foundation may publish revised and/or new versions+of the General Public License from time to time. Such new versions will+be similar in spirit to the present version, but may differ in detail to+address new problems or concerns.++Each version is given a distinguishing version number. If the Program+specifies a version number of this License which applies to it and "any+later version", you have the option of following the terms and conditions+either of that version or of any later version published by the Free+Software Foundation. If the Program does not specify a version number of+this License, you may choose any version ever published by the Free Software+Foundation.++ 10. If you wish to incorporate parts of the Program into other free+programs whose distribution conditions are different, write to the author+to ask for permission. For software which is copyrighted by the Free+Software Foundation, write to the Free Software Foundation; we sometimes+make exceptions for this. Our decision will be guided by the two goals+of preserving the free status of all derivatives of our free software and+of promoting the sharing and reuse of software generally.++ NO WARRANTY++ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,+REPAIR OR CORRECTION.++ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE+POSSIBILITY OF SUCH DAMAGES.++ END OF TERMS AND CONDITIONS++ How to Apply These Terms to Your New Programs++ If you develop a new program, and you want it to be of the greatest+possible use to the public, the best way to achieve this is to make it+free software which everyone can redistribute and change under these terms.++ To do so, attach the following notices to the program. It is safest+to attach them to the start of each source file to most effectively+convey the exclusion of warranty; and each file should have at least+the "copyright" line and a pointer to where the full notice is found.++ {description}+ Copyright (C) {year} {fullname}++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License along+ with this program; if not, write to the Free Software Foundation, Inc.,+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.++Also add information on how to contact you by electronic and paper mail.++If the program is interactive, make it output a short notice like this+when it starts in an interactive mode:++ Gnomovision version 69, Copyright (C) year name of author+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.+ This is free software, and you are welcome to redistribute it+ under certain conditions; type `show c' for details.++The hypothetical commands `show w' and `show c' should show the appropriate+parts of the General Public License. Of course, the commands you use may+be called something other than `show w' and `show c'; they could even be+mouse-clicks or menu items--whatever suits your program.++You should also get your employer (if you work as a programmer) or your+school, if any, to sign a "copyright disclaimer" for the program, if+necessary. Here is a sample; alter the names:++ Yoyodyne, Inc., hereby disclaims all copyright interest in the program+ `Gnomovision' (which makes passes at compilers) written by James Hacker.++ {signature of Ty Coon}, 1 April 1989+ Ty Coon, President of Vice++This General Public License does not permit incorporating your program into+proprietary programs. If your program is a subroutine library, you may+consider it more useful to permit linking proprietary applications with the+library. If this is what you want to do, use the GNU Lesser General+Public License instead of this License.
− LICENSE.md
@@ -1,339 +0,0 @@-GNU GENERAL PUBLIC LICENSE- Version 2, June 1991-- Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA- Everyone is permitted to copy and distribute verbatim copies- of this license document, but changing it is not allowed.-- Preamble-- The licenses for most software are designed to take away your-freedom to share and change it. By contrast, the GNU General Public-License is intended to guarantee your freedom to share and change free-software--to make sure the software is free for all its users. This-General Public License applies to most of the Free Software-Foundation's software and to any other program whose authors commit to-using it. (Some other Free Software Foundation software is covered by-the GNU Lesser General Public License instead.) You can apply it to-your programs, too.-- When we speak of free software, we are referring to freedom, not-price. Our General Public Licenses are designed to make sure that you-have the freedom to distribute copies of free software (and charge for-this service if you wish), that you receive source code or can get it-if you want it, that you can change the software or use pieces of it-in new free programs; and that you know you can do these things.-- To protect your rights, we need to make restrictions that forbid-anyone to deny you these rights or to ask you to surrender the rights.-These restrictions translate to certain responsibilities for you if you-distribute copies of the software, or if you modify it.-- For example, if you distribute copies of such a program, whether-gratis or for a fee, you must give the recipients all the rights that-you have. You must make sure that they, too, receive or can get the-source code. And you must show them these terms so they know their-rights.-- We protect your rights with two steps: (1) copyright the software, and-(2) offer you this license which gives you legal permission to copy,-distribute and/or modify the software.-- Also, for each author's protection and ours, we want to make certain-that everyone understands that there is no warranty for this free-software. If the software is modified by someone else and passed on, we-want its recipients to know that what they have is not the original, so-that any problems introduced by others will not reflect on the original-authors' reputations.-- Finally, any free program is threatened constantly by software-patents. We wish to avoid the danger that redistributors of a free-program will individually obtain patent licenses, in effect making the-program proprietary. To prevent this, we have made it clear that any-patent must be licensed for everyone's free use or not licensed at all.-- The precise terms and conditions for copying, distribution and-modification follow.-- GNU GENERAL PUBLIC LICENSE- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION-- 0. This License applies to any program or other work which contains-a notice placed by the copyright holder saying it may be distributed-under the terms of this General Public License. The "Program", below,-refers to any such program or work, and a "work based on the Program"-means either the Program or any derivative work under copyright law:-that is to say, a work containing the Program or a portion of it,-either verbatim or with modifications and/or translated into another-language. (Hereinafter, translation is included without limitation in-the term "modification".) Each licensee is addressed as "you".--Activities other than copying, distribution and modification are not-covered by this License; they are outside its scope. The act of-running the Program is not restricted, and the output from the Program-is covered only if its contents constitute a work based on the-Program (independent of having been made by running the Program).-Whether that is true depends on what the Program does.-- 1. You may copy and distribute verbatim copies of the Program's-source code as you receive it, in any medium, provided that you-conspicuously and appropriately publish on each copy an appropriate-copyright notice and disclaimer of warranty; keep intact all the-notices that refer to this License and to the absence of any warranty;-and give any other recipients of the Program a copy of this License-along with the Program.--You may charge a fee for the physical act of transferring a copy, and-you may at your option offer warranty protection in exchange for a fee.-- 2. You may modify your copy or copies of the Program or any portion-of it, thus forming a work based on the Program, and copy and-distribute such modifications or work under the terms of Section 1-above, provided that you also meet all of these conditions:-- a) You must cause the modified files to carry prominent notices- stating that you changed the files and the date of any change.-- b) You must cause any work that you distribute or publish, that in- whole or in part contains or is derived from the Program or any- part thereof, to be licensed as a whole at no charge to all third- parties under the terms of this License.-- c) If the modified program normally reads commands interactively- when run, you must cause it, when started running for such- interactive use in the most ordinary way, to print or display an- announcement including an appropriate copyright notice and a- notice that there is no warranty (or else, saying that you provide- a warranty) and that users may redistribute the program under- these conditions, and telling the user how to view a copy of this- License. (Exception: if the Program itself is interactive but- does not normally print such an announcement, your work based on- the Program is not required to print an announcement.)--These requirements apply to the modified work as a whole. If-identifiable sections of that work are not derived from the Program,-and can be reasonably considered independent and separate works in-themselves, then this License, and its terms, do not apply to those-sections when you distribute them as separate works. But when you-distribute the same sections as part of a whole which is a work based-on the Program, the distribution of the whole must be on the terms of-this License, whose permissions for other licensees extend to the-entire whole, and thus to each and every part regardless of who wrote it.--Thus, it is not the intent of this section to claim rights or contest-your rights to work written entirely by you; rather, the intent is to-exercise the right to control the distribution of derivative or-collective works based on the Program.--In addition, mere aggregation of another work not based on the Program-with the Program (or with a work based on the Program) on a volume of-a storage or distribution medium does not bring the other work under-the scope of this License.-- 3. You may copy and distribute the Program (or a work based on it,-under Section 2) in object code or executable form under the terms of-Sections 1 and 2 above provided that you also do one of the following:-- a) Accompany it with the complete corresponding machine-readable- source code, which must be distributed under the terms of Sections- 1 and 2 above on a medium customarily used for software interchange; or,-- b) Accompany it with a written offer, valid for at least three- years, to give any third party, for a charge no more than your- cost of physically performing source distribution, a complete- machine-readable copy of the corresponding source code, to be- distributed under the terms of Sections 1 and 2 above on a medium- customarily used for software interchange; or,-- c) Accompany it with the information you received as to the offer- to distribute corresponding source code. (This alternative is- allowed only for noncommercial distribution and only if you- received the program in object code or executable form with such- an offer, in accord with Subsection b above.)--The source code for a work means the preferred form of the work for-making modifications to it. For an executable work, complete source-code means all the source code for all modules it contains, plus any-associated interface definition files, plus the scripts used to-control compilation and installation of the executable. However, as a-special exception, the source code distributed need not include-anything that is normally distributed (in either source or binary-form) with the major components (compiler, kernel, and so on) of the-operating system on which the executable runs, unless that component-itself accompanies the executable.--If distribution of executable or object code is made by offering-access to copy from a designated place, then offering equivalent-access to copy the source code from the same place counts as-distribution of the source code, even though third parties are not-compelled to copy the source along with the object code.-- 4. You may not copy, modify, sublicense, or distribute the Program-except as expressly provided under this License. Any attempt-otherwise to copy, modify, sublicense or distribute the Program is-void, and will automatically terminate your rights under this License.-However, parties who have received copies, or rights, from you under-this License will not have their licenses terminated so long as such-parties remain in full compliance.-- 5. You are not required to accept this License, since you have not-signed it. However, nothing else grants you permission to modify or-distribute the Program or its derivative works. These actions are-prohibited by law if you do not accept this License. Therefore, by-modifying or distributing the Program (or any work based on the-Program), you indicate your acceptance of this License to do so, and-all its terms and conditions for copying, distributing or modifying-the Program or works based on it.-- 6. Each time you redistribute the Program (or any work based on the-Program), the recipient automatically receives a license from the-original licensor to copy, distribute or modify the Program subject to-these terms and conditions. You may not impose any further-restrictions on the recipients' exercise of the rights granted herein.-You are not responsible for enforcing compliance by third parties to-this License.-- 7. If, as a consequence of a court judgment or allegation of patent-infringement or for any other reason (not limited to patent issues),-conditions are imposed on you (whether by court order, agreement or-otherwise) that contradict the conditions of this License, they do not-excuse you from the conditions of this License. If you cannot-distribute so as to satisfy simultaneously your obligations under this-License and any other pertinent obligations, then as a consequence you-may not distribute the Program at all. For example, if a patent-license would not permit royalty-free redistribution of the Program by-all those who receive copies directly or indirectly through you, then-the only way you could satisfy both it and this License would be to-refrain entirely from distribution of the Program.--If any portion of this section is held invalid or unenforceable under-any particular circumstance, the balance of the section is intended to-apply and the section as a whole is intended to apply in other-circumstances.--It is not the purpose of this section to induce you to infringe any-patents or other property right claims or to contest validity of any-such claims; this section has the sole purpose of protecting the-integrity of the free software distribution system, which is-implemented by public license practices. Many people have made-generous contributions to the wide range of software distributed-through that system in reliance on consistent application of that-system; it is up to the author/donor to decide if he or she is willing-to distribute software through any other system and a licensee cannot-impose that choice.--This section is intended to make thoroughly clear what is believed to-be a consequence of the rest of this License.-- 8. If the distribution and/or use of the Program is restricted in-certain countries either by patents or by copyrighted interfaces, the-original copyright holder who places the Program under this License-may add an explicit geographical distribution limitation excluding-those countries, so that distribution is permitted only in or among-countries not thus excluded. In such case, this License incorporates-the limitation as if written in the body of this License.-- 9. The Free Software Foundation may publish revised and/or new versions-of the General Public License from time to time. Such new versions will-be similar in spirit to the present version, but may differ in detail to-address new problems or concerns.--Each version is given a distinguishing version number. If the Program-specifies a version number of this License which applies to it and "any-later version", you have the option of following the terms and conditions-either of that version or of any later version published by the Free-Software Foundation. If the Program does not specify a version number of-this License, you may choose any version ever published by the Free Software-Foundation.-- 10. If you wish to incorporate parts of the Program into other free-programs whose distribution conditions are different, write to the author-to ask for permission. For software which is copyrighted by the Free-Software Foundation, write to the Free Software Foundation; we sometimes-make exceptions for this. Our decision will be guided by the two goals-of preserving the free status of all derivatives of our free software and-of promoting the sharing and reuse of software generally.-- NO WARRANTY-- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,-REPAIR OR CORRECTION.-- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE-POSSIBILITY OF SUCH DAMAGES.-- END OF TERMS AND CONDITIONS-- How to Apply These Terms to Your New Programs-- If you develop a new program, and you want it to be of the greatest-possible use to the public, the best way to achieve this is to make it-free software which everyone can redistribute and change under these terms.-- To do so, attach the following notices to the program. It is safest-to attach them to the start of each source file to most effectively-convey the exclusion of warranty; and each file should have at least-the "copyright" line and a pointer to where the full notice is found.-- {description}- Copyright (C) {year} {fullname}-- This program is free software; you can redistribute it and/or modify- it under the terms of the GNU General Public License as published by- the Free Software Foundation; either version 2 of the License, or- (at your option) any later version.-- This program is distributed in the hope that it will be useful,- but WITHOUT ANY WARRANTY; without even the implied warranty of- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU General Public License for more details.-- You should have received a copy of the GNU General Public License along- with this program; if not, write to the Free Software Foundation, Inc.,- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.--Also add information on how to contact you by electronic and paper mail.--If the program is interactive, make it output a short notice like this-when it starts in an interactive mode:-- Gnomovision version 69, Copyright (C) year name of author- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.- This is free software, and you are welcome to redistribute it- under certain conditions; type `show c' for details.--The hypothetical commands `show w' and `show c' should show the appropriate-parts of the General Public License. Of course, the commands you use may-be called something other than `show w' and `show c'; they could even be-mouse-clicks or menu items--whatever suits your program.--You should also get your employer (if you work as a programmer) or your-school, if any, to sign a "copyright disclaimer" for the program, if-necessary. Here is a sample; alter the names:-- Yoyodyne, Inc., hereby disclaims all copyright interest in the program- `Gnomovision' (which makes passes at compilers) written by James Hacker.-- {signature of Ty Coon}, 1 April 1989- Ty Coon, President of Vice--This General Public License does not permit incorporating your program into-proprietary programs. If your program is a subroutine library, you may-consider it more useful to permit linking proprietary applications with the-library. If this is what you want to do, use the GNU Lesser General-Public License instead of this License.
− demo.md
@@ -1,129 +0,0 @@-----cref: False-codeBlockCaptions: True-figureTitle: "Figure \\#"-lofTitle: "## List of Figures"-lotTitle: "## List of Tables"-tableTemplate: "*$$tableTitle$$ $$i$$*$$titleDelim$$ $$t$$"-autoSectionLabels: True------This is a demo file for pandoc-crossref. With this filter, you can cross-reference figures (see [@fig:figure1;@fig:figure2;@fig:figure3]), display equations (see @eq:eqn1), tables (see [@tbl:table1]) and sections ([@sec:sec1; @sec:sec2; @sec:caption-attr; @sec:table-capts; @sec:wrapping-div])--For immediate example, see @fig:figure0--{#fig:figure0}--There is also support for code blocks, for example, [@lst:captionAttr; @lst:tableCaption; @lst:wrappingDiv]--It's possible to capitalize reference prefixes, like this: [@Fig:figure1].--In case of multiple references, capitalization is determined by first reference. [@Fig:figure1; @fig:figure2] is capitalized, while [@fig:figure2; @Fig:figure1] is not.--It is also possible to mix different references, like [@fig:figure1; @tbl:table1; @lst:captionAttr; @lst:tableCaption; @fig:figure2; @fig:figure3], which will be grouped in order they are specified. You can even intermix this with regular citations, although it's not recommended: [@fig:figure1; @tbl:table1; @unprocessedCitation]--You can also have custom chapter reference labels, like @sec:custlabs--Subfigures are supported, see [@fig:subfigures; @fig:subfigureB]--# Chapter 1. Figures {#sec:sec1}--{#fig:figure1}--{#fig:figure2}--{#fig:figure3}----<div id="fig:subfigures">---{#fig:subfigureB}--Subfigures caption-</div>--# Chapter 2. Equations {#sec:sec2}--Display equations are labelled and numbered--$$ P_i(x) = \sum_i a_i x^i $$ {#eq:eqn1}--Since 0.1.6.0 those can also appear in the middle of paragraph-$$a x^2 + b x^2 + c = 0$${#eq:quadr} like this.--# Chapter 3. Tables--| First Header | Second Header |-|:-------------|:--------------|-| Content Cell | Content Cell |-| Content Cell | Content Cell |--: Table example {#tbl:table1}--Table without caption:--| First Header | Second Header |-|:-------------|:--------------|-| Content Cell | Content Cell |-| Content Cell | Content Cell |--# Chapter 4. Code blocks--There are a couple options for code block labels. Those work only if code block id starts with `lst:`, e.g. `{#lst:label}`--## `caption` attribute {#sec:caption-attr}--`caption` attribute will be treated as code block caption. If code block has both id and `caption` attributes, it will be treated as numbered code block.--```{#lst:captionAttr .haskell caption="Listing caption"}-main :: IO ()-main = putStrLn "Hello World!"-```--\pagebreak--## Table-style captions {#sec:table-capts}--Enabled with `codeBlockCaptions` metadata option. If code block is immediately-adjacent to paragraph, starting with `Listing: ` or `: `, said paragraph will be-treated as code block caption.--Listing: Listing caption--```{#lst:tableCaption .haskell}-main :: IO ()-main = putStrLn "Hello World!"-```--## Wrapping div--Wrapping code block without label in a div with id `lst:...` and class, starting with `listing`, and adding paragraph before code block, but inside div, will treat said paragraph as code block caption.--<div id="lst:wrappingDiv" class="listing">-Listing caption-```{.haskell}-main :: IO ()-main = putStrLn "Hello World!"-```-</div>--# Unnumbered chapter. {-}--This chapter doesn't change chapter prefix of referenced elements, instead keeping number of previous chapter, e.g.-$$ S(x) = \int_{x_1}^{x_2} a x+b \ \mathrm{d}x $$ {#eq:eqn2}--# Chapter 5. Reference lists--It's also possible to show lists of figures and tables, like this:--\listoffigures--\listoftables--\listoflistings--# Appendix A. Custom labels {label=AppA}--## This section will have custom label {#sec:custlabs label=CustLab}
+ docs/demo/demo.md view
@@ -0,0 +1,133 @@+---+codeBlockCaptions: True+figureTitle: |+ Figure #+lofTitle: |+ ## List of Figures+lotTitle: |+ ## List of Tables+tableTemplate: |+ *$$tableTitle$$ $$i$$*$$titleDelim$$ $$t$$+autoSectionLabels: True+title: pandoc-crossref demo document+---++This is a demo file for pandoc-crossref. With this filter, you can cross-reference figures (see [@fig:figure1;@fig:figure2;@fig:figure3]), display equations (see @eq:eqn1), tables (see [@tbl:table1]) and sections ([@sec:sec1; @sec:sec2; @sec:caption-attr; @sec:table-capts; @sec:wrapping-div])++For immediate example, see @fig:figure0++{#fig:figure0}++There is also support for code blocks, for example, [@lst:captionAttr; @lst:tableCaption; @lst:wrappingDiv]++It's possible to capitalize reference prefixes, like this: [@Fig:figure1].++In case of multiple references, capitalization is determined by first reference. [@Fig:figure1; @fig:figure2] is capitalized, while [@fig:figure2; @Fig:figure1] is not.++It is also possible to mix different references, like [@fig:figure1; @tbl:table1; @lst:captionAttr; @lst:tableCaption; @fig:figure2; @fig:figure3], which will be grouped in order they are specified. You can even intermix this with regular citations, although it's not recommended: [@fig:figure1; @tbl:table1; @unprocessedCitation]++You can also have custom chapter reference labels, like @sec:custlabs++Subfigures are supported, see [@fig:subfigures; @fig:subfigureB]++# Chapter 1. Figures {#sec:sec1}++{#fig:figure1}++{#fig:figure2}++{#fig:figure3}++++<div id="fig:subfigures">+++{#fig:subfigureB}++Subfigures caption+</div>++# Chapter 2. Equations {#sec:sec2}++Display equations are labelled and numbered++$$ P_i(x) = \sum_i a_i x^i $$ {#eq:eqn1}++Since 0.1.6.0 those can also appear in the middle of paragraph+$$a x^2 + b x^2 + c = 0$${#eq:quadr} like this.++# Chapter 3. Tables++| First Header | Second Header |+|:-------------|:--------------|+| Content Cell | Content Cell |+| Content Cell | Content Cell |++: Table example {#tbl:table1}++Table without caption:++| First Header | Second Header |+|:-------------|:--------------|+| Content Cell | Content Cell |+| Content Cell | Content Cell |++# Chapter 4. Code blocks++There are a couple options for code block labels. Those work only if code block id starts with `lst:`, e.g. `{#lst:label}`++## `caption` attribute {#sec:caption-attr}++`caption` attribute will be treated as code block caption. If code block has both id and `caption` attributes, it will be treated as numbered code block.++```{#lst:captionAttr .haskell caption="Listing caption"}+main :: IO ()+main = putStrLn "Hello World!"+```++\pagebreak++## Table-style captions {#sec:table-capts}++Enabled with `codeBlockCaptions` metadata option. If code block is immediately+adjacent to paragraph, starting with `Listing: ` or `: `, said paragraph will be+treated as code block caption.++Listing: Listing caption++```{#lst:tableCaption .haskell}+main :: IO ()+main = putStrLn "Hello World!"+```++## Wrapping div++Wrapping code block without label in a div with id `lst:...` and class, starting with `listing`, and adding paragraph before code block, but inside div, will treat said paragraph as code block caption.++<div id="lst:wrappingDiv" class="listing">+Listing caption+```{.haskell}+main :: IO ()+main = putStrLn "Hello World!"+```+</div>++# Unnumbered chapter. {-}++This chapter doesn't change chapter prefix of referenced elements, instead keeping number of previous chapter, e.g.+$$ S(x) = \int_{x_1}^{x_2} a x+b \ \mathrm{d}x $$ {#eq:eqn2}++# Chapter 5. Reference lists++It's also possible to show lists of figures and tables, like this:++\listoffigures++\listoftables++\listoflistings++# Appendix A. Custom labels {label=AppA}++## This section will have custom label {#sec:custlabs label=CustLab}
+ docs/index.md view
@@ -0,0 +1,523 @@+---+author: Nikolay Yakimov+date: November 2017+title: 'pandoc-crossref(1)'+---++pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them.++# Caveats++## LaTeX output and `--include-in-header`++pandoc-crossref uses metadata variable `header-includes` to add LaTeX definitions to output. However, Pandoc's command line option `--include-in-header`/`-H` overrides this variable. If you need to use `--include-in-header`, add pandoc-crossref-specific definitions as well. See [LaTeX customization](#latex-customization) for more information.++## pandoc-citeproc and pandoc-crossref++Since pandoc-crossref uses the same citation syntax as pandoc-citeproc, you *have* to run former *before* latter. For example:++```+pandoc -F pandoc-crossref -F pandoc-citeproc file.md -o file.html+```++## Note on leading/trailing spaces in metadata options++Leading and trailing spaces in YAML metadata will most likely be stripped by either YAML parser or Pandoc itself. If you need leading and/or trailing spaces in pandoc-crossref metadata variables, use html entity for space instead, i.e. ` `. For example, if you want reference ranges to be delimited by a dash with spaces (e.g. `2 - 5`), include the following in YAML metadata:++```yaml+rangeDelim: ' - '+```++or pass `-MrangeDelim=' - '` to pandoc on command line.++You can use other html entites of course, like ` ` etc.++# Syntax++Syntax is loosely based on discussion in <https://github.com/jgm/pandoc/issues/813>++## Image labels++```markdown+{#fig:label}+```++To label an (implicit) figure, append `{#fig:label}` (with `label` being something unique to reference this figure by) immediately after image definition.++This only works on implicit figures, i.e. an image occurring by itself in a paragraph (which will be rendered as a figure with caption by pandoc)++Image block and label *can not* be separated by spaces.++### Subfigures++It's possible to group figures as subfigures. Basic syntax is as follows:++```markdown+<div id="fig:figureRef">+{#fig:figureRefA}++{#fig:figureRefB}++Caption of figure+</div>+```++To sum up, subfigures are made with a div having a figure `id`. Contents of said div consist of several paragraphs. All but last paragraphs contain one subfigure each, with captions, images and (optionally) reference attributes. Last paragraph contains figure caption.++If you put more than one figure in the paragraph, those will still be rendered, but Pandoc will omit subfigure caption in most outputs (but it will work as expected with LaTeX). You can use output-specific hacks to work around that, or use `subfigGrid` (see below).++Output is customizable, with metadata fields. See [Customization](#customization) for more information.++Default settings will produce the following equivalent Markdown from example above:++```markdown+<div id="fig:figureRef" class="subfigures">++{#fig:figureRefA}++{#fig:figureRefB}++Figure 1: Caption of figure. a — subfigure 1 caption, b — subfigure 2+caption++</div>+```++References to subfigures will be rendered as `figureNumber (subfigureNumber)`, e.g., in this particular example, `[@fig:figureRefA]` will produce `fig. 1 (a)`.++You can add `nocaption` class to an image to suppress subfigure caption altogether. Note that it will still be counted.++#### Subfigure grid++If you need to align subfigures in a grid, and using output format styles is not an option, you can use `subfigGrid` option. That will typeset subfigures inside a table.++Rows are formed by different paragraphs, with each image in a separate column.++Column widths will be taken from `width` attributes of corresponding images, e.g.++```markdown+<div id="fig:coolFig">+{#fig:cfa width=30%}+{#fig:cfb width=60%}+{#fig:cfc width=10%}++{#fig:cfd}+{#fig:cfe}+{#fig:cff}++Cool figure!+</div>+```++will produce a table with columns of 30%, 60% and 10% respectively.++Only first row of images is considered for table width computation, other rows are completely ignored.++*Anything* except images is silently ignored. So any text, spaces, soft line breaks etc will silently disappear from output. That doesn't apply to caption paragraph, obviously.++All images will have width attribute automatically set to `100%` in order to fill whole column.++Specifying width in anything but `%` will throw an error.++If width for some images in first row is not specified, those will span equally in the remaining space.++If width isn't specified for any image in first row, those will span equally on 99% of page width (due to Pandoc otherwise omitting width attribute for table).++This option is ignored with LaTeX output, but paragraph breaks should produce similar effect, so images should be typeset correctly. TL;DR you don't need `subfigGrid` enabled for it to work with LaTeX, but you can still enable it.++## Equation labels++```markdown+$$ math $$ {#eq:label}+```++To label a display equation, append `{#eq:label}` (with `label` being something unique to reference this equation by) immediately after math block.++Math block and label *can* be separated by one or more spaces.++You can also number all display equations with `autoEqnLabels` metadata setting (see below). Note, however, that you won't be able to reference equations without explicit labels.++Equations numbers will be typeset inside math with `\qquad` before them. If you want to use tables instead, use `tableEqns` option. Depending on output format, tables might work better or worse than `\qquad`.++## Table labels++```markdown+a b c+--- --- ---+1 2 3+4 5 6++: Caption {#tbl:label}+```++To label a table, append `{#tbl:label}` at the end of table caption (with `label` being something unique to reference this table by). Caption and label *must* be separated by at least one space.++## Section labels++You can also reference sections of any level. Section labels use native pandoc syntax, but must start with "sec:", e.g.++```markdown+ Section {#sec:section}+```++You can also use `autoSectionLabels` variable to automatically prepend all section labels (automatically generated with pandoc included) with "sec:". Bear in mind that references can't contain periods, commas etc, so some auto-generated labels will still be unusable.++WARNING: With LaTeX output, you have to invoke pandoc with `--number-sections`, otherwise section labels won't work. It's also advised with other output formats, since with no numbers in section titles, it would be hard to navigate anyway.++### Section numbering++Pandoc doesn't properly support numbering sections in some output formats, and section reference labels (see below).++You can let pandoc-crossref handle section numbering instedad. This is done via `numberSections` and `sectionsDepth` metadata options.++`numberSections` controls if pandoc-crossref handles numbering sections, while `sectionsDepth` controls what sections are numbered.++Set `sectionsDepth` to `0` to make section numbering consistent with `chaptersDepth`.++If `sectionsDepth` value is lesser than `0`, all sections will be numbered.++Otherwise, only header levels up to and including `sectionsDepth` will be numbered.++## Section reference labels++***Not currently supported with LaTeX output***++If you want to reference some section by a pre-defined label instead of by number, you can specify section attribute `label`, like this:++```markdown+ Section {label="Custom Label"}+```++This label will be used instead of section number in `chapters` output and when referencing section directly (with `@sec:section`).++Note that with `chapters` output with depth>1, only given section will be referenced by custom label, e.g. with++```markdown+ Chapter 1.++# Section with custom label {#sec:scl label="SCL"}++{#fig:figure}+```++`@sec:scl` will translate into `sec. 1.SCL`, and `@fig:figure` into `fig. 1.SCL.1`++## Code Block labels++There are a couple options to add code block labels. Those work only if code block id starts with `lst:`, e.g. `{#lst:label}`++### `caption` attribute++`caption` attribute will be treated as code block caption. If code block has both id and `caption` attributes, it will be treated as numbered code block.++<pre>+```{#lst:code .haskell caption="Listing caption"}+main :: IO ()+main = putStrLn "Hello World!"+```+</pre>++### Table-style captions++Enabled with `codeBlockCaptions` metadata option. If code block is immediately+adjacent to paragraph, starting with `Listing: ` or `: `, said paragraph will be+treated as code block caption.++<pre>+Listing: Listing caption++```{#lst:code .haskell}+main :: IO ()+main = putStrLn "Hello World!"+```+</pre>++or++<pre>+```{#lst:code .haskell}+main :: IO ()+main = putStrLn "Hello World!"+```++: Listing caption+</pre>++It also allows to specify label in caption, as do tables, for example:++<pre>+```haskell+main :: IO ()+main = putStrLn "Hello World!"+```++: Listing caption {#lst:code}+</pre>++### Wrapping div++Wrapping code block without label in a div with id `lst:...` and class, starting with `listing`, and adding paragraph before code block, but inside div, will treat said paragraph as code block caption.++<pre>+<div id="lst:code" class="listing">+Listing caption+```{.haskell}+main :: IO ()+main = putStrLn "Hello World!"+```+</div>+</pre>++## References++```markdown+[@fig:label1;@fig:label2;...] or [@eq:label1;@eq:label2;...] or [@tbl:label1;@tbl:label2;...] or @fig:label or @eq:label or @tbl:label+```++Reference syntax heavily relies on citation syntax. Basic reference is created by writing `@`, then basically desired label with prefix. It is also possible to reference a group of objects, by putting them into brackets with `;` as separator. Similar objects will be grouped in order of them appearing in citation brackets, and sequential reference numbers will be shortened, e.g. `1,2,3` will be shortened to `1-3`.++You can capitalize first reference character to get capitalized prefix, e.g. `[@Fig:label1]` will produce `Fig. ...` by default. Capitalized prefixes are derived automatically by capitalizing first letter of every word in non-capitalized prefix, unless overridden with metadata settings. See [Customization](#customization) for more information.++### Linking references++To make references into hyperlinks to referenced element, enable `linkReferences` metadata option. This has no effect on LaTeX output, since in this case, hyperlinking references is handled with `hyperref` LaTeX package.++### Custom prefix per-reference++It's possible to provide your own prefix per-reference, f.ex. `[Prefix @reference]` will replace default prefix (`fig.`/`sec.`/etc) with prefix verbatim, e.g. `[Prefix @fig:1]` will be rendered as `Prefix 1` instead of `fig. 1`.++In citation group, citations with the same prefix will be grouped. So, for example `[A @fig:1; A @fig:2; B @fig:3]` will turn into `A 1, 2, B 3`. It can be used to an advantage, although it's a bit more cumbersome than it should be, e.g. `[Appendices @sec:A1; Appendices @sec:A2; Appendices @sec:A3]` will turn into `Appendices @A1-@A3` (with `@A1` and `@A3` being relevant section numbers). Note that non-contiguous sequences of identical prefixes *will not* be grouped.++***Not supported with cleveref LaTeX output.***++### Prefix suppression++Prepending `-` before `@`, like so `[-@citation]`, will suppress default prefix, e.g. `[-@fig:1]` will produce just `1` (or whatever number it happens to be) without `fig.` prefix.++In citation group, citations with and without prefixes will be in different groups. So `[-@fig:1; @fig:2; -@fig:3]` will be rendered as `1, fig. 2, 3`, so be careful with this feature. Again, non-contiguous sequences are not grouped together.++## Lists++It's possible to use raw latex commands `\listoffigures`, `\listoftables` and `listoflistings`, which will produce ordered list of figure/table/listings titles, in order of appearance in document.++`\listoflistings` depends on other options, and is defined in preamble, so it will work reliably only with standalone/pdf output.++# Usage++Run pandoc with `--filter` option, passing path to pandoc-crossref executable, or simply `pandoc-crossref`, if it's in PATH:++`pandoc --filter pandoc-crossref`++If you installed with cabal, it's most likely located in `$HOME/.cabal/bin` on \*NIX systems, `$HOME/Library/Haskell/bin` on Macs, or in `%AppData%\cabal\bin` on Windows.++## Customization++There are several parameters that can be set via YAML metadata (either by passing `-M` to `pandoc`, or by setting it in source markdown)++A list of variables follows.++### General options++* `cref`: if True, latex export will use `\cref` from cleveref package. Only relevant for LaTeX output. `\usepackage{cleveref}` will be automatically added to `header-includes`.+* `chapters`: if True, number elements as `chapter.item`, and restart `item` on each first-level heading (as `--chapters` for latex/pdf output)+* `chaptersDepth`, default `1`: header level to treat as "chapter". If `chaptersDepth>1`, then items will be prefixed with several numbers, corresponding to header numbers, e.g. `fig. 1.4.3`.+* `numberSections`, default `false`: if True, pandoc-crossref will prepend section number to section titles (as counted by pandoc-crossref itself).+* `sectionsDepth`, default `0`:+ - sectionsDepth < 0 -- number all sections+ - sectionsDepth == 0 -- be consistent with `chaptersDepths`+ - sectionsDepth > 0 -- number section levels up to and including `sectionsDepth`+* `listings`: if True, generate code blocks for `listings` package. Only relevant for LaTeX output. `\usepackage{listings}` will be automatically added to `header-includes`. You need to specify `--listings` option as well.+* `codeBlockCaptions`: if True, parse table-style code block captions.+* `autoSectionLabels`, default `false`: Automatically prefix all section labels with `sec:`. Note that this messes with pandoc's automatic header references.+* `autoEqnLabels`, default `false`: Automatically number all display equations (i.e. ones defined using `$$...$$`/`\[...\]`). Note that you won't be able to reference equations without explicit labels.+* `tableEqns`, default `false`: Typeset equations and equation numbers in tables instead of embedding numbers into equations themselves. Depending on output format, this might work better or worse.++### Item title format++* `figureTitle`, default `Figure`: Word(s) to prepend to figure titles, e.g. `Figure 1: Description`+* `tableTitle`, default `Table`: Word(s) to prepend to table titles, e.g. `Table 1: Description`+* `listingTitle`, default `Listing`: Word(s) to prepend to listing titles, e.g. `Listing 1: Description`+* `titleDelim`, default `:`: What to put between object number and caption text.++#### Subfigure-specific++See [Subfigures](#subfigures)++* `ccsDelim`, default `, `: delimiter for collected subfigure captions. See [Subfigures](#subfigures) and [Templates](#templates)+* `ccsLabelSep`, default ` — `: delimiter used between subfigure label and subfigure caption in collected captions. See [Subfigures](#subfigures) and [Templates](#templates)+* `subfigGrid`, default `false`. If true, typeset subfigures inside a table. Ignored with LaTeX output. See [Subfigures](#subfigures)++### List titles++* `lofTitle`, default `# List of Figures`: Title for list of figures (lof)+* `lotTitle`, default `# List of Tables`: Title for list of tables (lot)+* `lolTitle`, default `# List of Listings`: Title for list of listings (lol)++### Reference format++* `figPrefix`, default `fig.`, `figs.`: Prefix for references to figures, e.g. `figs. 1-3`+* `eqnPrefix`, default `eq.`, `eqns.`: Prefix for references to equations, e.g. `eqns. 3,4`+* `tblPrefix`, default `tbl.`, `tbls.`: Prefix for references to tables, e.g. `tbl. 2`+* `lstPrefix`, default `lst.`, `lsts.`: Prefix for references to lists, e.g. `lsts. 2,5`+* `secPrefix`, default `sec.`, `secs.`: Prefix for references to sections, e.g. `secs. 2,5`+* `chapDelim`, default `.`: Delimiter between chapter number and item number.+* `rangeDelim`, default `-`: Delimiter between reference ranges, e.g. `eq. 2-5`+* `pairDelim`, default `, `: Delimiter between pair of reference ranges, e.g. `eq. 2-5 <and> 7-9`, or `eq. 2 <and> 7`, but `eq. 2, 4, 6`+* `lastDelim`, default `, `: Delimiter between second-to-last and last reference ranges, e.g. `eq. 2-5, 6-8 <and> 10`. `pairDelim` overrides this for cases of exactly two references/ranges.+* `refDelim`, default `, `: Delimiter between references, e.g. `eq. 2, 5, 7` or `eq. 2-4, 6-8`+* `linkReferences`, default `false`: Make references hyperlinks to the referenced element+* `nameInLink`, default `false`: For single-element references, inlcude prefix into hyperlink (when using `linkReferences`)++Note that none of the `*Delim` options are honored with cleveref output. Use cleveref's customization options instead.++`figPrefix`, `eqnPrefix`, `tblPrefix`, `lstPrefix` can be YAML arrays. That way, value at index corresponds to total number of references in group, f.ex.++```yaml+figPrefix:+ - "fig."+ - "figs."+```++Will result in all single-value references prefixed with "fig.", and all reference groups of two and more will be prefixed with "figs.":++```markdown+[@fig:one] -> fig. 1+[@fig:one; @fig:two] -> figs. 1, 2+[@fig:one; @fig:two; @fig:three] -> figs. 1-3+```++They can be YAML strings as well. In that case, prefix would be the same regardless of number of references.++They can also be used with first character capitalized, i.e. `FigPrefix`, etc. In this case, these settings will override default reference capitailzation settings.++### Custom numbering++See [Custom Numbering Schemes](#custom-numbering-schemes)++* `figLabels`, default unset: custom numbering scheme for figures.+* `subfigLabels`, default `alpha a`: custom numbering scheme for subfigures.+* `eqnLabels`, default unset: custom numbering scheme for equations.+* `tblLabels`, default unset: custom numbering scheme for tables.+* `lstLabels`, default unset: custom numbering scheme for listings.+* `secLabels`, default unset: custom numbering scheme for sections.++### Item title templates++See [Templates](#templates)++* `figureTemplate`, default `$$figureTitle$$ $$i$$$$titleDelim$$ $$t$$`: template for figure captions+* `tableTemplate`, default `$$tableTitle$$ $$i$$$$titleDelim$$ $$t$$`: template for table captions+* `listingTemplate`, default `$$listingTitle$$ $$i$$$$titleDelim$$ $$t$$`: template for listing captions++#### Subfigure templates++See [Subfigures](#subfigures)++* `subfigureTemplate`, default `$$figureTitle$$ $$i$$$$titleDelim$$ $$t$$. $$ccs$$`: template for subfigure divs captions.+* `subfigureChildTemplate`, default `$$i$$`: template for actual subfigure captions.+* `ccsTemplate`, default `$$i$$$$ccsLabelSep$$$$t$$`: template for collected subfigure captions.++### Reference templates++See [Templates](#templates)++* `figPrefixTemplate`, default `$$p$$ $$i$$` -- figure reference template+* `eqnPrefixTemplate`, default `$$p$$ $$i$$` -- equation reference template+* `tblPrefixTemplate`, default `$$p$$ $$i$$` -- table reference template+* `lstPrefixTemplate`, default `$$p$$ $$i$$` -- listing reference template+* `secPrefixTemplate`, default `$$p$$ $$i$$` -- section reference template+* `refIndexTemplate`, default `$$i$$$$suf$$` -- individual reference index template+* `subfigureRefIndexTemplate`, default `$$i$$$$suf$$ ($$s$$)` -- subfigure reference index template++### LaTeX customization++Support for above variables with LaTeX/PDF output is limited. In particular, the following variables are honored:++* `figureTitle`+* `tableTitle`+* `listingTitle`+* `lofTitle` -- ignores formatting+* `lotTitle` -- ignores formatting+* `lolTitle` -- ignores formatting+* `*Prefix`, upper-/lowercase and single/plural form. Note that with cleveref output, if `*Prefix` is array, only first two items are used, and the rest is ignored.++Templates are *not* supported.++You can add arbitrary LaTeX commands to document header, however, using `header-includes` metadata field. Please bear in mind, that pandoc-crossref up to and including 0.1.2.1 requires `header-includes` to be YAML array, e.g.++```yaml+header-includes:+ - "\\newcommand{\\pcdoc}{Pandoc-crossref documentation}"+```++This will be added *before* any customization applied by pandoc-crossref. For a complete list of what is added to template, consult [ModifyMeta.hs][ModifyMeta.hs].++[ModifyMeta.hs]: https://github.com/lierdakil/pandoc-crossref/blob/master/src/Util/ModifyMeta.hs++## Templates++pandoc-crossref supports advanced caption customization via caption templates. Templates are specified as YAML metadata variables (see [Customization](#customization)), and are parsed as default Pandoc Markdown. Variables are specified with display math syntax, i.e. `$$var$$` in a template will be replaced with value of variable `var`.+Variables can be specified in YAML metadata block, or from command line (with `-M` switch). There are two special variables, that are set internally:++* `i` -- object number, possibly with chapter number (if `chapter=True`)+* `t` -- object caption, as given in source Markdown++Also there is a number of specific variables that are meaningful only in certain contexts:++* `ccs` -- collected subfigure captions. Only applicable to `subfigureTemplate`. Collected captions will be separated by `ccsDelim` and individual captions will be printed with `ccsTemplate`. See [Subfigures](#subfigures)+* `suf` -- reference suffix, applicable to `refIndexTemplate`, `subfigureRefIndexTemplate`+* `s` -- subfigure index, applicable to `subfigureRefIndexTemplate`++`xPrefixTemplate`, where `x` is `fig`, `eqn`, etc, are a special case. Those don't have `t` variable, since there is no caption in source markdown, but instead have `p` variable, that binds to relevant `xPrefix`. This is done this way, since actual prefix vaule can depend on `i`.++Please note that at the moment, templates are not supported with LaTeX/PDF output.++## Custom Numbering Schemes++It's possible to use other numbering schemes apart from arabic. This is controlled by several metadata options, consult [Customization](#customization) for a list. Possible values are:++- `arabic` -- arabic numbers (1, 2, 3 ...)+- `roman` -- roman numbers (I, II, III, IV, ...)+- `alpha x`, where `x` is first letter to start from. This will work for any letter, but will use UTF-8 codepage to determine what's next, so using something strange is not advised. For example, you can safely use `alpha a` to get lowercase latin letters for 26 figures. After that, it will get weird (since basic latin alphabet has 26 letters). Specifically, it will go into characters space (`{`, `|`, `}`, etc). You can consult http://www.fileformat.info/info/unicode/block/basic_latin/utf8test.htm for general idea on letter progression.+- list of strings. You can define a YAML array for numbers. Mapping is 1:1. For example,+ ```yaml+ figLabels: [α, β, γ, 1, 2, 3, I, II, III]+ ```+ will give first figure label 'α', second -- 'β', etc.++ Note that it will repeat last item in list indefinitely if there are more images than items in list.++## Settings file++It is also possible to set variables used by pandoc-crossref with a separate YAML file. If a given variable is not set in metadata, then pandoc-crossref will attempt to read it from file specified by `crossrefYaml` metadata variable, or, if not set, from `pandoc-crossref.yaml` from current working directory. This allows for reusable configurations. One possible application is ad-hoc internationalization.++For example, consider `$HOME/misc/pandoc-crossref-es.yaml`:++```yaml+figureTitle: "Figura"+tableTitle: "Tabla"+figPrefix: "fig."+eqnPrefix: "ec."+tblPrefix: "tbl."+loftitle: "# Lista de figuras"+lotTitle: "# Lista de tablas"+```++pandoc-crossref will send this data to pandoc wrapped in lines of `---`. The YAML file's first line should specify a variable; it will not pass the variables if it is `---` or a blank line.++One could use this with pandoc-crossref as follows:++`pandoc -F pandoc-crossref.hs -M "crossrefYaml=$HOME/misc/pandoc-crossref-es.yaml"`++You can also use global configuration files, which are expected in `$HOME/.pandoc-crossref/config.yaml` and `$HOME/.pandoc-crossref/config-$FORMAT.yaml`, where `$FORMAT` is output format, f.ex. `latex` or `epub`. On Windows, `$HOME` in general resolves to user's root directory, e.g. `C:\Users\username\`.++Priorities are as follows (from highest to lowest):++- document metadata+- `crossrefYaml`/`$CWD/pandoc-crossref.yaml`+- `$HOME/.pandoc-crossref/config-$FORMAT.yaml`+- `$HOME/.pandoc-crossref/config.yaml`++# License++This software is licensed under GNU GPL v2
lib/Text/Pandoc/CrossRef.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ {- | Module : Text.Pandoc.CrossRef Copyright : Copyright (C) 2015 Nikolay Yakimov@@ -55,6 +75,7 @@ , runCrossRef , runCrossRefIO , module SG+ , defaultMeta , CrossRefM , CrossRefEnv(..) ) where
lib/Text/Pandoc/CrossRef/References.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ module Text.Pandoc.CrossRef.References ( module X ) where import Text.Pandoc.CrossRef.References.Types as X
lib/Text/Pandoc/CrossRef/References/Blocks.hs view
@@ -1,11 +1,31 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ {-# LANGUAGE Rank2Types, MultiWayIf #-} module Text.Pandoc.CrossRef.References.Blocks ( replaceAll ) where import Text.Pandoc.Definition-import Text.Pandoc.Builder (text, toList)-import Text.Pandoc.Shared (stringify, normalizeSpaces)+import qualified Text.Pandoc.Builder as B+import Text.Pandoc.Shared (stringify) import Control.Monad.State hiding (get, modify) import Data.List import Data.Maybe@@ -52,7 +72,7 @@ index <- get curChap modify secRefs $ M.insert label' RefRec { refIndex=index- , refTitle=normalizeSpaces text'+ , refTitle= text' , refSubfigure = Nothing } cc <- get curChap@@ -71,9 +91,9 @@ = do idxStr <- replaceAttr opts (Right label) (lookup "label" attrs) caption imgRefs let (cont, st) = runState (runReplace (mkRR $ replaceSubfigs opts') $ init images) def- collectedCaptions =- intercalate (ccsDelim opts)- $ map (collectCaps . snd)+ collectedCaptions = B.toList $+ intercalate' (B.fromList $ ccsDelim opts)+ $ map (B.fromList . collectCaps . snd) $ sortOn (refIndex . snd) $ filter (not . null . refTitle . snd) $ M.toList@@ -98,12 +118,12 @@ case outFormat opts of f | isFormat "latex" f -> replaceNoRecurse $ Div nullAttr $- [ RawBlock (Format "tex") "\\begin{figure}\n\\centering" ]+ [ RawBlock (Format "latex") "\\begin{figure}\n\\centering" ] ++ cont ++- [ Para [RawInline (Format "tex") "\\caption"+ [ Para [RawInline (Format "latex") "\\caption" , Span nullAttr caption]- , RawBlock (Format "tex") $ mkLaTeXLabel label- , RawBlock (Format "tex") "\\end{figure}"]+ , RawBlock (Format "latex") $ mkLaTeXLabel label+ , RawBlock (Format "latex") "\\end{figure}"] _ -> replaceNoRecurse $ Div (label, "subfigures":cls, attrs) $ toTable cont capt where opts' = opts@@ -151,7 +171,7 @@ let title' = case outFormat opts of f | isFormat "latex" f ->- RawInline (Format "tex") (mkLaTeXLabel label) : title+ RawInline (Format "latex") (mkLaTeXLabel label) : title _ -> applyTemplate idxStr title $ tableTemplate opts replaceNoRecurse $ Div divOps [Table title' align widths header cells] replaceBlock opts cb@(CodeBlock (label, classes, attrs) code)@@ -165,13 +185,13 @@ --if not using listings, however, wrap it in a codelisting environment | isFormat "latex" f -> replaceNoRecurse $ Div nullAttr [- RawBlock (Format "tex")+ RawBlock (Format "latex") $ "\\begin{codelisting}\n\\caption{"++caption++"}" , cb- , RawBlock (Format "tex") "\\end{codelisting}"+ , RawBlock (Format "latex") "\\end{codelisting}" ] _ -> do- let cap = toList $ text caption+ let cap = B.toList $ B.text caption idxStr <- replaceAttr opts (Right label) (lookup "label" attrs) cap lstRefs let caption' = applyTemplate idxStr cap $ listingTemplate opts replaceNoRecurse $ Div (label, "listing":classes, []) [@@ -191,13 +211,13 @@ --if not using listings, however, wrap it in a codelisting environment | isFormat "latex" f -> replaceNoRecurse $ Div nullAttr [- RawBlock (Format "tex") "\\begin{codelisting}"+ RawBlock (Format "latex") "\\begin{codelisting}" , Para [- RawInline (Format "tex") "\\caption"+ RawInline (Format "latex") "\\caption" , Span nullAttr caption ] , CodeBlock (label,classes,attrs) code- , RawBlock (Format "tex") "\\end{codelisting}"+ , RawBlock (Format "latex") "\\end{codelisting}" ] _ -> do idxStr <- replaceAttr opts (Right label) (lookup "label" attrs) caption lstRefs@@ -229,7 +249,7 @@ = case outFormat opts of f | isFormat "latex" f -> let eqn = "\\begin{equation}"++eq++mkLaTeXLabel label++"\\end{equation}"- in replaceNoRecurse $ RawInline (Format "tex") eqn+ in replaceNoRecurse $ RawInline (Format "latex") eqn _ -> do (eq', _) <- replaceEqn opts attrs eq replaceNoRecurse $ Span attrs [Math DisplayMath eq']@@ -268,9 +288,11 @@ divBlocks (Table title align widths header cells) | not $ null title , Just label <- getRefLabel "tbl" [last title]- = Div (label,[],[]) [Table (init title) align widths header cells]+ = Div (label,[],[]) [Table (dropWhileEnd isSpace $ init title) align widths header cells]+ where isSpace = (||) <$> (==Space) <*> (==SoftBreak) divBlocks x = x + splitMath :: [Block] -> [Block] splitMath (Para ils:xs) | length ils > 1 = map Para (split [] [] ils) ++ xs@@ -304,7 +326,7 @@ error $ "Duplicate label: " ++ label' modify prop $ M.insert label' RefRec { refIndex= index- , refTitle=normalizeSpaces title+ , refTitle= title , refSubfigure = Nothing } return $ chapPrefix (chapDelim o) index@@ -314,16 +336,16 @@ let title' = fromMaybe title $ stripPrefix "fig:" title texlabel | null label = []- | otherwise = [RawInline (Format "tex") $ mkLaTeXLabel label]+ | otherwise = [RawInline (Format "latex") $ mkLaTeXLabel label] texalt | "nocaption" `elem` cls = [] | otherwise = concat- [ [ RawInline (Format "tex") "["]+ [ [ RawInline (Format "latex") "["] , alt- , [ RawInline (Format "tex") "]"]+ , [ RawInline (Format "latex") "]"] ] img = Image (label, cls, attrs) alt (src, title') in concat [- [ RawInline (Format "tex") "\\subfloat" ]+ [ RawInline (Format "latex") "\\subfloat" ] , texalt , [Span nullAttr $ img:texlabel] ]
lib/Text/Pandoc/CrossRef/References/List.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ module Text.Pandoc.CrossRef.References.List (listOf) where import Text.Pandoc.Definition@@ -12,11 +32,11 @@ listOf :: Options -> [Block] -> WS [Block] listOf Options{outFormat=f} x | isFormat "latex" f = return x-listOf opts (Para [RawInline (Format "tex") "\\listoffigures"]:xs)+listOf opts (RawBlock (Format "latex") "\\listoffigures":xs) = get imgRefs >>= makeList opts lofTitle xs-listOf opts (Para [RawInline (Format "tex") "\\listoftables"]:xs)+listOf opts (RawBlock (Format "latex") "\\listoftables":xs) = get tblRefs >>= makeList opts lotTitle xs-listOf opts (Para [RawInline (Format "tex") "\\listoflistings"]:xs)+listOf opts (RawBlock (Format "latex") "\\listoflistings":xs) = get lstRefs >>= makeList opts lolTitle xs listOf _ x = return x
lib/Text/Pandoc/CrossRef/References/Refs.hs view
@@ -1,8 +1,27 @@-{-# LANGUAGE TupleSections #-}+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ module Text.Pandoc.CrossRef.References.Refs (replaceRefs) where import Text.Pandoc.Definition-import Text.Pandoc.Shared (normalizeInlines, normalizeSpaces)+import Text.Pandoc.Builder import Control.Monad.State hiding (get, modify) import Data.List import qualified Data.List.HT as HT@@ -23,8 +42,7 @@ replaceRefs :: Options -> [Inline] -> WS [Inline] replaceRefs opts (Cite cits _:xs)- = (++ xs) `fmap` intercalate [Str ",", Space] `fmap`- mapM replaceRefs' (groupBy eqPrefix cits)+ = toList . (<> fromList xs) . intercalate' (text ", ") . map fromList <$> mapM replaceRefs' (groupBy eqPrefix cits) where eqPrefix a b = uncurry (==) $ (fmap uncapitalizeFirst . getLabelPrefix . citationId) <***> (a,b)@@ -34,12 +52,13 @@ = replaceRefs'' prefix opts cits' | otherwise = return [Cite cits' il'] where- il' = normalizeInlines $- [Str "["]- ++intercalate [Str ";", Space] (map citationToInlines cits')- ++[Str "]"]- citationToInlines c = normalizeSpaces $- citationPrefix c ++ [Space, Str $ "@"++citationId c] ++ citationSuffix c+ il' = toList $+ str "["+ <> intercalate' (text "; ") (map citationToInlines cits')+ <> str "]"+ citationToInlines c =+ fromList (citationPrefix c) <> text ("@" ++ citationId c)+ <> fromList (citationSuffix c) replaceRefs'' = case outFormat opts of f | isFormat "latex" f -> replaceRefsLatex _ -> replaceRefsOther@@ -88,7 +107,7 @@ | cref opts = replaceRefsLatex' prefix opts cits | otherwise- = normalizeInlines . intercalate [Str ",", Space] <$>+ = toList . intercalate' (text ", ") . map fromList <$> mapM (replaceRefsLatex' prefix opts) (groupBy citationGroupPred cits) replaceRefsLatex' :: String -> Options -> [Citation] -> WS [Inline]@@ -128,8 +147,7 @@ where p = (++ ":") . takeWhile (/=':') $ lab replaceRefsOther :: String -> Options -> [Citation] -> WS [Inline]-replaceRefsOther prefix opts cits =- normalizeInlines . intercalate [Str ",", Space] <$>+replaceRefsOther prefix opts cits = toList . intercalate' (text ", ") . map fromList <$> mapM (replaceRefsOther' prefix opts) (groupBy citationGroupPred cits) citationGroupPred :: Citation -> Citation -> Bool@@ -145,11 +163,11 @@ | all null $ map citationPrefix cits = cmap $ getRefPrefix opts prefix cap (length cits - 1) | otherwise- = cmap ((citationPrefix (head cits) ++ [Space]) ++)+ = cmap $ toList . ((fromList (citationPrefix (head cits)) <> space) <>) . fromList cmap f [Link attr t w] | nameInLink opts = [Link attr (f t) w] cmap f x = f x- return $ normalizeInlines $ writePrefix (makeIndices opts indices)+ return $ writePrefix (makeIndices opts indices) data RefData = RefData { rdLabel :: String , rdIdx :: Maybe Index@@ -201,20 +219,20 @@ f (x:xs) = [RefRange x (last xs)] -- shorten more than two values format :: [RefItem] -> [Inline] format [] = []- format [x] = show'' x- format [x, y] = show'' x ++ pairDelim o ++ show'' y- format xs = intercalate (refDelim o) init' ++ lastDelim o ++ last'+ format [x] = toList $ show'' x+ format [x, y] = toList $ show'' x <> fromList (pairDelim o) <> show'' y+ format xs = toList $ intercalate' (fromList $ refDelim o) init' <> fromList (lastDelim o) <> last' where initlast [] = error "emtpy list in initlast" initlast [y] = ([], y) initlast (y:ys) = first (y:) $ initlast ys (init', last') = initlast $ map show'' xs- show'' :: RefItem -> [Inline]+ show'' :: RefItem -> Inlines show'' (RefSingle x) = show' x- show'' (RefRange x y) = show' x ++ rangeDelim o ++ show' y- show' :: RefData -> [Inline]+ show'' (RefRange x y) = show' x <> fromList (rangeDelim o) <> show' y+ show' :: RefData -> Inlines show' RefData{rdLabel=l, rdIdx=Just i, rdSubfig = sub, rdSuffix = suf}- | linkReferences o = [Link nullAttr txt ('#':l,[])]- | otherwise = txt+ | linkReferences o = link ('#':l) "" (fromList txt)+ | otherwise = fromList txt where txt | Just sub' <- sub@@ -232,4 +250,4 @@ in applyTemplate' vars $ refIndexTemplate o show' RefData{rdLabel=l, rdIdx=Nothing, rdSuffix = suf} = trace ("Undefined cross-reference: " ++ l)- (Strong [Str $ "¿" ++ l ++ "?"] : suf)+ (strong (text $ "¿" ++ l ++ "?") <> fromList suf)
lib/Text/Pandoc/CrossRef/References/Types.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ {-# LANGUAGE TemplateHaskell #-} module Text.Pandoc.CrossRef.References.Types where
lib/Text/Pandoc/CrossRef/Util/CodeBlockCaptions.hs view
@@ -1,10 +1,29 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ module Text.Pandoc.CrossRef.Util.CodeBlockCaptions ( mkCodeBlockCaptions ) where import Text.Pandoc.Definition-import Text.Pandoc.Shared (normalizeSpaces) import Data.List (isPrefixOf, stripPrefix) import Data.Maybe (fromMaybe) import Text.Pandoc.CrossRef.References.Types@@ -38,9 +57,9 @@ getCodeBlockCaption :: [Inline] -> Maybe [Inline] getCodeBlockCaption ils- | Just caption <- [Str "Listing:",Space] `stripPrefix` normalizeSpaces ils+ | Just caption <- [Str "Listing:",Space] `stripPrefix` ils = Just caption- | Just caption <- [Str ":",Space] `stripPrefix` normalizeSpaces ils+ | Just caption <- [Str ":",Space] `stripPrefix` ils = Just caption | otherwise = Nothing
lib/Text/Pandoc/CrossRef/Util/CustomLabels.hs view
@@ -1,8 +1,27 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ module Text.Pandoc.CrossRef.Util.CustomLabels (customLabel) where import Text.Pandoc.Definition import Text.Pandoc.CrossRef.Util.Meta-import Control.Monad import Data.List import Text.Numeral.Roman @@ -10,17 +29,17 @@ customLabel meta ref i | refLabel <- takeWhile (/=':') ref , Just cl <- lookupMeta (refLabel++"Labels") meta- = mkLabel i cl+ = mkLabel i (refLabel++"Labels") cl | otherwise = Nothing -mkLabel :: Int -> MetaValue -> Maybe String-mkLabel i lt- | toString lt == Just "arabic"+mkLabel :: Int -> String -> MetaValue -> Maybe String+mkLabel i n lt+ | toString n lt == "arabic" = Nothing- | toString lt == Just "roman"+ | toString n lt == "roman" = Just $ toRoman i- | Just (startWith:_) <- join $ stripPrefix "alpha " `fmap` toString lt+ | Just (startWith:_) <- stripPrefix "alpha " $ toString n lt = Just [[startWith..] !! (i-1)]- | Just val <- join $ toString `fmap` getList (i-1) lt+ | Just val <- toString n <$> getList (i-1) lt = Just val | otherwise = error $ "Unknown numeration type: " ++ show lt
− lib/Text/Pandoc/CrossRef/Util/Gap.hs
@@ -1,6 +0,0 @@-module Text.Pandoc.CrossRef.Util.Gap where--import qualified Text.Pandoc as P--readMarkdown :: P.ReaderOptions -> String -> P.Pandoc-readMarkdown = (either (error . show) id .) . P.readMarkdown
lib/Text/Pandoc/CrossRef/Util/Meta.hs view
@@ -1,56 +1,101 @@-{-# LANGUAGE FlexibleContexts #-}-module Text.Pandoc.CrossRef.Util.Meta where+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru> -import Text.Pandoc.CrossRef.Util.Gap+This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}++{-# LANGUAGE FlexibleContexts, Rank2Types #-}+module Text.Pandoc.CrossRef.Util.Meta (+ getMetaList+ , getMetaBool+ , getMetaInlines+ , getMetaBlock+ , getMetaString+ , getList+ , toString+ , toInlines+ , tryCapitalizeM+ ) where+ import Text.Pandoc.CrossRef.Util.Util-import Text.Pandoc.Shared (stringify) import Text.Pandoc.Definition-import Data.Maybe (fromMaybe)+import Text.Pandoc.Builder import Data.Default import Text.Pandoc.Walk+import Text.Pandoc.Shared hiding (capitalize) -getMetaList :: (Default a) => (MetaValue -> Maybe a) -> String -> Meta -> Int -> a-getMetaList f name meta i = fromMaybe def $ lookupMeta name meta >>= getList i >>= f+getMetaList :: (Default a) => (MetaValue -> a) -> String -> Meta -> Int -> a+getMetaList f name meta i = maybe def f $ lookupMeta name meta >>= getList i getMetaBool :: String -> Meta -> Bool-getMetaBool name meta = fromMaybe False $ lookupMeta name meta >>= toBool+getMetaBool = getScalar toBool getMetaInlines :: String -> Meta -> [Inline]-getMetaInlines name meta = fromMaybe [] $ lookupMeta name meta >>= toInlines+getMetaInlines = getScalar toInlines getMetaBlock :: String -> Meta -> [Block]-getMetaBlock name meta = fromMaybe [] $ lookupMeta name meta >>= toBlocks+getMetaBlock = getScalar toBlocks getMetaString :: String -> Meta -> String-getMetaString name meta = fromMaybe [] $ lookupMeta name meta >>= toString+getMetaString = getScalar toString -toInlines :: MetaValue -> Maybe [Inline]-toInlines (MetaString s) =- return $ getInlines $ readMarkdown def s- where getInlines (Pandoc _ bs) = concatMap getInline bs- getInline (Plain ils) = ils- getInline (Para ils) = ils- getInline _ = []-toInlines (MetaInlines s) = return s-toInlines _ = Nothing+getScalar :: Def b => (String -> MetaValue -> b) -> String -> Meta -> b+getScalar conv name meta = maybe def' (conv name) $ lookupMeta name meta -toBool :: MetaValue -> Maybe Bool-toBool (MetaBool b) = return b-toBool _ = Nothing+class Def a where+ def' :: a -toBlocks :: MetaValue -> Maybe [Block]-toBlocks (MetaBlocks bs) = return bs-toBlocks (MetaInlines ils) = return [Plain ils]-toBlocks (MetaString s) =- return $ getBlocks $ readMarkdown def s- where getBlocks (Pandoc _ bs) = bs-toBlocks _ = Nothing+instance Def Bool where+ def' = False -toString :: MetaValue -> Maybe String-toString (MetaString s) = Just s-toString (MetaBlocks b) = Just $ stringify b-toString (MetaInlines i) = Just $ stringify i-toString _ = Nothing+instance Def [a] where+ def' = []++unexpectedError :: forall a. String -> String -> MetaValue -> a+unexpectedError e n x = error $ "Expected " <> e <> " in metadata field " <> n <> " but got " <> g x+ where+ g (MetaBlocks _) = "blocks"+ g (MetaString _) = "string"+ g (MetaInlines _) = "inlines"+ g (MetaBool _) = "bool"+ g (MetaMap _) = "map"+ g (MetaList _) = "list"++toInlines :: String -> MetaValue -> [Inline]+toInlines _ (MetaBlocks s) = blocksToInlines s+toInlines _ (MetaInlines s) = s+toInlines _ (MetaString s) = toList $ text s+toInlines n x = unexpectedError "inlines" n x++toBool :: String -> MetaValue -> Bool+toBool _ (MetaBool b) = b+toBool n x = unexpectedError "bool" n x++toBlocks :: String -> MetaValue -> [Block]+toBlocks _ (MetaBlocks bs) = bs+toBlocks _ (MetaInlines ils) = [Plain ils]+toBlocks _ (MetaString s) = toList $ plain $ text s+toBlocks n x = unexpectedError "blocks" n x++toString :: String -> MetaValue -> String+toString _ (MetaString s) = s+toString _ (MetaBlocks b) = stringify b+toString _ (MetaInlines i) = stringify i+toString n x = unexpectedError "string" n x getList :: Int -> MetaValue -> Maybe MetaValue getList i (MetaList l) = l !!? i
lib/Text/Pandoc/CrossRef/Util/ModifyMeta.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ module Text.Pandoc.CrossRef.Util.ModifyMeta ( modifyMeta@@ -9,6 +29,8 @@ import Text.Pandoc.CrossRef.Util.Options import Text.Pandoc.CrossRef.Util.Meta import Text.Pandoc.CrossRef.Util.Util+import qualified Data.Text as T+import Control.Monad.Writer modifyMeta :: Options -> Meta -> Meta modifyMeta opts meta@@ -19,19 +41,22 @@ | otherwise = meta where headerInc :: Maybe MetaValue -> MetaValue- headerInc Nothing = MetaList incList- headerInc (Just (MetaList x)) = MetaList $ x ++ incList- headerInc (Just x) = MetaList $ x:incList- incList = map MetaString $- [ "\\makeatletter" ] ++- subfig ++- floatnames ++- listnames ++- [ x | x <- codelisting, not $ listings opts] ++- lolcommand ++- [ x | x <- cleveref, cref opts] ++- [ x | x <- cleverefCodelisting, cref opts && not (listings opts)] ++- [ "\\makeatother" ]+ headerInc Nothing = incList+ headerInc (Just (MetaList x)) = MetaList $ x ++ [incList]+ headerInc (Just x) = MetaList [x, incList]+ incList = MetaBlocks $ return $ RawBlock (Format "latex") $ unlines $ execWriter $ do+ tell [ "\\makeatletter" ]+ tell subfig+ tell floatnames+ tell listnames+ unless (listings opts) $+ tell codelisting+ tell lolcommand+ when (cref opts) $ do+ tell cleveref+ unless (listings opts) $+ tell cleverefCodelisting+ tell [ "\\makeatother" ] where subfig = [ usepackage [] "subfig"@@ -64,29 +89,26 @@ , "}" ] | otherwise = ["\\newcommand*\\listoflistings{\\listof{codelisting}{"++metaString' "lolTitle"++"}}"]- cleveref = [- usepackage cleverefOpts "cleveref"- , "\\crefname{figure}" ++ prefix figPrefix False- , "\\crefname{table}" ++ prefix tblPrefix False- , "\\crefname{equation}" ++ prefix eqnPrefix False- , "\\crefname{listing}" ++ prefix lstPrefix False- , "\\crefname{section}" ++ prefix secPrefix False- , "\\Crefname{figure}" ++ prefix figPrefix True- , "\\Crefname{table}" ++ prefix tblPrefix True- , "\\Crefname{equation}" ++ prefix eqnPrefix True- , "\\Crefname{listing}" ++ prefix lstPrefix True- , "\\Crefname{section}" ++ prefix secPrefix True- ]+ cleveref = [ usepackage cleverefOpts "cleveref" ]+ <> crefname "figure" figPrefix+ <> crefname "table" tblPrefix+ <> crefname "equation" eqnPrefix+ <> crefname "listing" lstPrefix+ <> crefname "section" secPrefix cleverefCodelisting = [ "\\crefname{codelisting}{\\cref@listing@name}{\\cref@listing@name@plural}" , "\\Crefname{codelisting}{\\Cref@listing@name}{\\Cref@listing@name@plural}" ] cleverefOpts | nameInLink opts = [ "nameinlink" ] | otherwise = []+ crefname n f = [+ "\\crefname{" ++ n ++ "}" ++ prefix f False+ , "\\Crefname{" ++ n ++ "}" ++ prefix f True+ ] usepackage [] p = "\\@ifpackageloaded{"++p++"}{}{\\usepackage{"++p++"}}" usepackage xs p = "\\@ifpackageloaded{"++p++"}{}{\\usepackage"++o++"{"++p++"}}" where o = "[" ++ intercalate "," xs ++ "]"- toLatex = writeLaTeX def . Pandoc nullMeta . return . Plain+ toLatex = either (error . show) T.unpack . runPure . writeLaTeX def . Pandoc nullMeta . return . Plain metaString s = toLatex $ getMetaInlines s meta metaString' s = toLatex [Str $ getMetaString s meta] prefix f uc = "{" ++ toLatex (f opts uc 0) ++ "}" ++
lib/Text/Pandoc/CrossRef/Util/Options.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ module Text.Pandoc.CrossRef.Util.Options (Options(..)) where import Text.Pandoc.Definition import Text.Pandoc.CrossRef.Util.Template
lib/Text/Pandoc/CrossRef/Util/PandocOrphans.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ {-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Text.Pandoc.CrossRef.Util.PandocOrphans where
lib/Text/Pandoc/CrossRef/Util/Settings.hs view
@@ -1,7 +1,27 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>+Copyright (C) 2017 Masamichi Hosoda <trueroad@trueroad.jp>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ module Text.Pandoc.CrossRef.Util.Settings (getSettings, defaultMeta) where -import Text.Pandoc hiding (readMarkdown)-import Text.Pandoc.CrossRef.Util.Gap+import Text.Pandoc import Text.Pandoc.Builder import Control.Exception (handle,IOException) @@ -11,6 +31,7 @@ import System.Directory import System.FilePath import System.IO+import qualified Data.Text as T getSettings :: Maybe Format -> Meta -> IO Meta getSettings fmt meta = do@@ -25,8 +46,9 @@ h <- openFile path ReadMode hSetEncoding h utf8 yaml <- hGetContents h- let Pandoc meta' _ = readMarkdown def ("---\n" ++ yaml ++ "\n---")+ Pandoc meta' _ <- readMd $ T.pack $ unlines ["---", yaml, "---"] return meta'+ readMd = handleError . runPure . readMarkdown def{readerExtensions=pandocExtensions} readFmtConfig home fmt' = readConfig (home </> ".pandoc-crossref" </> "config-" ++ fmtStr fmt' ++ ".yaml") handler :: IOException -> IO Meta handler _ = return nullMeta
lib/Text/Pandoc/CrossRef/Util/Settings/Gen.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ {-# LANGUAGE TemplateHaskell #-} -- {-# OPTIONS_GHC -ddump-splices #-} module Text.Pandoc.CrossRef.Util.Settings.Gen where
lib/Text/Pandoc/CrossRef/Util/Settings/Template.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ {-# LANGUAGE TemplateHaskell, RankNTypes, ViewPatterns, MultiWayIf #-} module Text.Pandoc.CrossRef.Util.Settings.Template where @@ -64,7 +84,7 @@ if | t' == boolT -> [|getMetaBool $(varName) $(dtv)|] | t' == intT -> [|read $ getMetaString $(varName) $(dtv)|]- | t' == funT -> [|tryCapitalizeM (flip (getMetaList toInlines) $(dtv)) $(varName)|]+ | t' == funT -> [|tryCapitalizeM (flip (getMetaList (toInlines $(varName))) $(dtv)) $(varName)|] | t' == inlT -> [|getMetaInlines $(varName) $(dtv)|] | t' == blkT -> [|getMetaBlock $(varName) $(dtv)|] | t' == tmplT -> [|makeTemplate $(dtv) $ getMetaInlines $(varName) $(dtv)|]
lib/Text/Pandoc/CrossRef/Util/Template.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ module Text.Pandoc.CrossRef.Util.Template ( Template , makeTemplate@@ -6,26 +26,26 @@ ) where import Text.Pandoc.Definition+import Text.Pandoc.Builder import Text.Pandoc.Generic-import Text.Pandoc.Shared (normalizeInlines)-import Data.Maybe-import Data.Map as M+import Data.Map as M hiding (toList, fromList, singleton) import Text.Pandoc.CrossRef.Util.Meta+import Control.Applicative type VarFunc = String -> Maybe MetaValue newtype Template = Template (VarFunc -> [Inline]) makeTemplate :: Meta -> [Inline] -> Template-makeTemplate dtv = Template . flip scan . scan (`lookupMeta` dtv)+makeTemplate dtv xs' = Template $ \vf -> scan (\var -> vf var <|> lookupMeta var dtv) xs' where scan = bottomUp . go- go vf (x@(Math DisplayMath var):xs) = replaceVar (vf var) [x] ++ xs- go _ x = x- replaceVar val def' = fromMaybe def' $ val >>= toInlines+ go vf (x@(Math DisplayMath var):xs) = toList $ fromList (replaceVar var (vf var) [x]) <> fromList xs+ go _ (x:xs) = toList $ singleton x <> fromList xs+ go _ [] = []+ replaceVar var val def' = maybe def' (toInlines ("variable " ++ var)) val applyTemplate' :: Map String [Inline] -> Template -> [Inline]-applyTemplate' vars (Template g) =- normalizeInlines $ g internalVars+applyTemplate' vars (Template g) = g internalVars where internalVars x | Just v <- M.lookup x vars = Just $ MetaInlines v internalVars _ = Nothing
lib/Text/Pandoc/CrossRef/Util/Util.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ {-# LANGUAGE RankNTypes #-} module Text.Pandoc.CrossRef.Util.Util ( module Text.Pandoc.CrossRef.Util.Util@@ -6,13 +26,19 @@ import Text.Pandoc.CrossRef.References.Types import Text.Pandoc.Definition+import Text.Pandoc.Builder+import Text.Pandoc.Class import Data.Char (toUpper, toLower, isUpper)-import Data.List (intercalate, isSuffixOf, isPrefixOf, stripPrefix)+import Data.List (isSuffixOf, isPrefixOf, stripPrefix) import Data.Maybe (fromMaybe) import Data.Generics import Text.Pandoc.Writers.LaTeX import Data.Default+import qualified Data.Text as T +intercalate' :: (Eq a, Monoid a, Foldable f) => a -> f a -> a+intercalate' s = foldr (\x acc -> if acc == mempty then x else x <> s <> acc) mempty+ isFormat :: String -> Maybe Format -> Bool isFormat fmt (Just (Format f)) = takeWhile (`notElem` "+-") f == fmt isFormat _ Nothing = False@@ -30,7 +56,7 @@ isFirstUpper [] = False chapPrefix :: [Inline] -> Index -> [Inline]-chapPrefix delim index = intercalate delim (map (return . Str . uncurry (fromMaybe . show)) index)+chapPrefix delim index = toList $ intercalate' (fromList delim) (map (str . uncurry (fromMaybe . show)) index) data ReplacedResult a = Replaced Bool a | NotReplaced Bool type GenRR m = forall a. Data a => (a -> m (ReplacedResult a))@@ -78,7 +104,8 @@ mkLaTeXLabel' :: String -> String mkLaTeXLabel' l =- let ll = writeLaTeX def $ Pandoc nullMeta [Div (l, [], []) []]+ let ll = either (error . show) T.unpack $+ runPure (writeLaTeX def $ Pandoc nullMeta [Div (l, [], []) []]) in takeWhile (/='}') . drop 1 . dropWhile (/='{') $ ll getRefLabel :: String -> [Inline] -> Maybe String
pandoc-crossref.cabal view
@@ -1,13 +1,15 @@--- This file has been generated from package.yaml by hpack version 0.17.1.+-- This file has been generated from package.yaml by hpack version 0.20.0. -- -- see: https://github.com/sol/hpack+--+-- hash: bff6647405df1883495f3afdc5a0a7b789940dec86718c25961f35c1a017d42f name: pandoc-crossref-version: 0.2.7.0+version: 0.3.0.0 synopsis: Pandoc filter for cross-references description: pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them.-license: GPL-2-license-file: LICENSE.md+license: GPL+license-file: LICENSE author: Nikolay Yakimov maintainer: root@livid.pp.ru category: Text@@ -21,7 +23,8 @@ test/demo.inc data-files:- demo.md+ docs/demo/demo.md+ docs/index.md test/m2m/delim/expect.md test/m2m/delim/expect.tex test/m2m/delim/input.md@@ -61,6 +64,26 @@ location: https://github.com/lierdakil/pandoc-crossref library+ hs-source-dirs:+ lib+ ghc-options: -Wall+ build-depends:+ base >=4.9 && <5+ , containers >=0.1 && <0.6+ , data-accessor >=0.2.2.6 && <0.3.0.0+ , data-accessor-template >=0.2.1.12 && <0.3.0.0+ , data-accessor-transformers >=0.2.1.6 && <0.3.0.0+ , data-default >=0.4 && <0.8+ , directory >=1 && <1.4+ , filepath >=1.1 && <1.5+ , mtl >=1.1 && <2.3+ , pandoc ==2.0.*+ , pandoc-types ==1.17.*+ , roman-numerals ==0.5.*+ , syb >=0.4 && <0.8+ , template-haskell >=2.7.0.0 && <3.0.0.0+ , text >=1.2.2 && <1.3+ , utility-ht >=0.0.11 && <0.1.0 exposed-modules: Text.Pandoc.CrossRef other-modules:@@ -71,7 +94,6 @@ Text.Pandoc.CrossRef.References.Types Text.Pandoc.CrossRef.Util.CodeBlockCaptions Text.Pandoc.CrossRef.Util.CustomLabels- Text.Pandoc.CrossRef.Util.Gap Text.Pandoc.CrossRef.Util.Meta Text.Pandoc.CrossRef.Util.ModifyMeta Text.Pandoc.CrossRef.Util.Options@@ -82,51 +104,38 @@ Text.Pandoc.CrossRef.Util.Template Text.Pandoc.CrossRef.Util.Util Paths_pandoc_crossref- build-depends:- base >=4.9 && <5- , pandoc ==1.19.*- , pandoc-types ==1.17.*- , mtl >=1.1 && <2.3- , containers >=0.1 && <0.6- , data-default >=0.4 && <0.8- , data-accessor >=0.2.2.6 && <0.3.0.0- , data-accessor-template >=0.2.1.12 && <0.3.0.0- , data-accessor-transformers >=0.2.1.6 && <0.3.0.0- , template-haskell >=2.7.0.0 && <3.0.0.0- , roman-numerals ==0.5.*- , syb >=0.4 && <0.8- , utility-ht >=0.0.11 && <0.1.0- , directory >=1 && <1.4- , filepath >=1.1 && <1.5- , text >=1.2.2 && <1.3- hs-source-dirs:- lib- ghc-options: -Wall default-language: Haskell2010 executable pandoc-crossref main-is: pandoc-crossref.hs+ hs-source-dirs:+ src+ ghc-options: -Wall build-depends: base >=4.9 && <5- , pandoc ==1.19.*- , pandoc-types ==1.17.*- , mtl >=1.1 && <2.3 , containers >=0.1 && <0.6- , data-default >=0.4 && <0.8 , data-accessor >=0.2.2.6 && <0.3.0.0 , data-accessor-template >=0.2.1.12 && <0.3.0.0 , data-accessor-transformers >=0.2.1.6 && <0.3.0.0- , template-haskell >=2.7.0.0 && <3.0.0.0- , roman-numerals ==0.5.*- , syb >=0.4 && <0.8- , utility-ht >=0.0.11 && <0.1.0+ , data-default >=0.4 && <0.8+ , deepseq >=1.4 && <1.5 , directory >=1 && <1.4 , filepath >=1.1 && <1.5- , text >=1.2.2 && <1.3+ , mtl >=1.1 && <2.3+ , open-browser >=0.2 && <0.3+ , optparse-applicative >=0.13 && <0.15+ , pandoc ==2.0.* , pandoc-crossref- hs-source-dirs:- src- ghc-options: -Wall+ , pandoc-types ==1.17.*+ , roman-numerals ==0.5.*+ , syb >=0.4 && <0.8+ , template-haskell >=2.7.0.0 && <3.0.0.0+ , temporary >=1.2 && <1.3+ , text >=1.2.2 && <1.3+ , utility-ht >=0.0.11 && <0.1.0+ other-modules:+ ManData+ Paths_pandoc_crossref default-language: Haskell2010 test-suite test-integrative@@ -137,23 +146,23 @@ ghc-options: -Wall -fno-warn-unused-do-bind -threaded build-depends: base >=4.9 && <5- , pandoc ==1.19.*- , pandoc-types ==1.17.*- , mtl >=1.1 && <2.3 , containers >=0.1 && <0.6- , data-default >=0.4 && <0.8 , data-accessor >=0.2.2.6 && <0.3.0.0 , data-accessor-template >=0.2.1.12 && <0.3.0.0 , data-accessor-transformers >=0.2.1.6 && <0.3.0.0- , template-haskell >=2.7.0.0 && <3.0.0.0- , roman-numerals ==0.5.*- , syb >=0.4 && <0.8- , utility-ht >=0.0.11 && <0.1.0+ , data-default >=0.4 && <0.8 , directory >=1 && <1.4 , filepath >=1.1 && <1.5- , text >=1.2.2 && <1.3- , pandoc-crossref , hspec >=2.4.4 && <3+ , mtl >=1.1 && <2.3+ , pandoc ==2.0.*+ , pandoc-crossref+ , pandoc-types ==1.17.*+ , roman-numerals ==0.5.*+ , syb >=0.4 && <0.8+ , template-haskell >=2.7.0.0 && <3.0.0.0+ , text >=1.2.2 && <1.3+ , utility-ht >=0.0.11 && <0.1.0 default-language: Haskell2010 test-suite test-pandoc-crossref@@ -165,22 +174,22 @@ ghc-options: -Wall -fno-warn-unused-do-bind -threaded build-depends: base >=4.9 && <5- , pandoc ==1.19.*- , pandoc-types ==1.17.*- , mtl >=1.1 && <2.3 , containers >=0.1 && <0.6- , data-default >=0.4 && <0.8 , data-accessor >=0.2.2.6 && <0.3.0.0 , data-accessor-template >=0.2.1.12 && <0.3.0.0 , data-accessor-transformers >=0.2.1.6 && <0.3.0.0- , template-haskell >=2.7.0.0 && <3.0.0.0- , roman-numerals ==0.5.*- , syb >=0.4 && <0.8- , utility-ht >=0.0.11 && <0.1.0+ , data-default >=0.4 && <0.8 , directory >=1 && <1.4 , filepath >=1.1 && <1.5- , text >=1.2.2 && <1.3 , hspec >=2.4.4 && <3+ , mtl >=1.1 && <2.3+ , pandoc ==2.0.*+ , pandoc-types ==1.17.*+ , roman-numerals ==0.5.*+ , syb >=0.4 && <0.8+ , template-haskell >=2.7.0.0 && <3.0.0.0+ , text >=1.2.2 && <1.3+ , utility-ht >=0.0.11 && <0.1.0 other-modules: Native Text.Pandoc.CrossRef@@ -191,7 +200,6 @@ Text.Pandoc.CrossRef.References.Types Text.Pandoc.CrossRef.Util.CodeBlockCaptions Text.Pandoc.CrossRef.Util.CustomLabels- Text.Pandoc.CrossRef.Util.Gap Text.Pandoc.CrossRef.Util.Meta Text.Pandoc.CrossRef.Util.ModifyMeta Text.Pandoc.CrossRef.Util.Options@@ -201,4 +209,5 @@ Text.Pandoc.CrossRef.Util.Settings.Template Text.Pandoc.CrossRef.Util.Template Text.Pandoc.CrossRef.Util.Util+ Paths_pandoc_crossref default-language: Haskell2010
+ src/ManData.hs view
@@ -0,0 +1,70 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}++{-# LANGUAGE TemplateHaskellQuotes #-}+module ManData where++import Language.Haskell.TH.Syntax+import qualified Data.Text as T+import System.IO+import qualified Text.Pandoc as P+import Control.DeepSeq+import Data.String+import Text.Pandoc.Highlighting (pygments)++dataFile :: FilePath+dataFile = "docs/index.md"++readDataFile :: IO String+readDataFile =+ withFile dataFile ReadMode $ \h -> do+ hSetEncoding h utf8+ cont <- hGetContents h+ return $!! cont++embedManual :: (P.Pandoc -> P.PandocPure T.Text) -> Q Exp+embedManual fmt = do+ qAddDependentFile dataFile+ d <- runIO readDataFile+ let pd = either (error . show) id $ P.runPure $ P.readMarkdown readerOpts (T.pack d)+ let txt = either (error . show) id $ P.runPure $ fmt pd+ strToExp $ T.unpack txt++readerOpts :: P.ReaderOptions+readerOpts = P.def{+ P.readerExtensions = P.enableExtension P.Ext_yaml_metadata_block P.githubMarkdownExtensions+ , P.readerStandalone = True+}++embedManualText :: Q Exp+embedManualText = embedManual $ P.writePlain P.def++embedManualHtml :: Q Exp+embedManualHtml = do+ t <- runIO $ fmap (either (error . show) id) $ P.runIO $ P.getDefaultTemplate "html5"+ embedManual $ P.writeHtml5String P.def{+ P.writerTemplate = Just t+ , P.writerHighlightStyle = Just pygments+ }++strToExp :: String -> Q Exp+strToExp s =+ return $ VarE 'fromString+ `AppE` LitE (StringL s)
src/pandoc-crossref.hs view
@@ -1,9 +1,71 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}++{-# LANGUAGE ApplicativeDo, TemplateHaskell #-} import Text.Pandoc+import Text.Pandoc.Builder import Text.Pandoc.JSON import Text.Pandoc.CrossRef+import Options.Applicative+import qualified Options.Applicative as O+import Control.Monad+import Paths_pandoc_crossref (version)+import Data.Version (showVersion)+import Web.Browser+import System.IO.Temp+import System.IO+import ManData+import Control.Concurrent +man, manHtml :: String+man = $(embedManualText)+manHtml = $(embedManualHtml)++data Flag = Version | Man | HtmlMan++run :: Parser (IO ())+run = do+ vers <- flag Nothing (Just Version) (long "version" <> short 'v' <> help "Print version")+ man' <- flag Nothing (Just Man) (long "man" <> help "Show manpage")+ hman <- flag Nothing (Just HtmlMan) (long "man-html" <> help "Show html manpage")+ fmt <- optional $ strArgument (metavar "FORMAT")+ return $ go (vers <|> man' <|> hman) fmt+ where+ go :: Maybe Flag -> Maybe String -> IO ()+ go (Just Version) _ = putStrLn $ showVersion version+ go (Just Man ) _ = putStrLn man+ go (Just HtmlMan) _ = withSystemTempFile "pandoc-crossref-manual.html" $ \fp h -> do+ hPutStrLn h manHtml+ hClose h+ void $ openBrowser $ "file:///" <> fp+ threadDelay 5000000+ return ()+ go Nothing _ = toJSONFilter f+ f fmt p@(Pandoc meta _) =+ runCrossRefIO meta fmt defaultCrossRefAction p+ main :: IO ()-main = toJSONFilter go+main = join $ execParser opts where- go fmt p@(Pandoc meta _) = runCrossRefIO meta fmt defaultCrossRefAction p+ opts = info (run <**> helper)+ ( fullDesc+ <> O.header "pandoc-crossref - Pandoc filter for cross-references"+ )
test/Native.hs view
@@ -1,3 +1,23 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ {-# LANGUAGE CPP #-} module Native where
test/demo-chapters.inc view
@@ -1,10 +1,10 @@- [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "demo",Space,Str "file",Space,Str "for",Space,Str "pandoc-crossref.",Space,Str "With",Space,Str "this",Space,Str "filter,",Space,Str "you",Space,Str "can",Space,Str "cross-reference",Space,Str "figures",Space,Str "(see",Space,Str "figs.\160\&1.1-1.3",Str "),",Space,Str "display",Space,Str "equations",Space,Str "(see",Space,Str "eq.\160\&2.1",Str "),",Space,Str "tables",Space,Str "(see",Space,Str "tbl.\160\&3.1",Str ")",Space,Str "and",Space,Str "sections",Space,Str "(",Str "secs.\160\&1,",Space,Str "2,",Space,Str "4.1-4.3",Str ")"]+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "demo",Space,Str "file",Space,Str "for",Space,Str "pandoc-crossref.",Space,Str "With",Space,Str "this",Space,Str "filter,",Space,Str "you",Space,Str "can",Space,Str "cross-reference",Space,Str "figures",Space,Str "(see",Space,Str "figs.\160\&1.1-1.3),",Space,Str "display",Space,Str "equations",Space,Str "(see",Space,Str "eq.\160\&2.1),",Space,Str "tables",Space,Str "(see",Space,Str "tbl.\160\&3.1)",Space,Str "and",Space,Str "sections",Space,Str "(",Str "secs.\160\&1,",Space,Str "2,",Space,Str "4.1-4.3)"] ,Para [Str "For",Space,Str "immediate",Space,Str "example,",Space,Str "see",Space,Str "fig.\160\&1"] ,Para [Image ("fig:figure0",[],[]) [Str "Figure",Space,Str "#",Space,Str "1:",Space,Str "A",Space,Str "figure"] ("img1.jpg","fig:")] ,Para [Str "There",Space,Str "is",Space,Str "also",Space,Str "support",Space,Str "for",Space,Str "code",Space,Str "blocks,",Space,Str "for",Space,Str "example,",Space,Str "lsts.\160\&4.1-4.3"]- ,Para [Str "It's",Space,Str "possible",Space,Str "to",Space,Str "capitalize",Space,Str "reference",Space,Str "prefixes,",Space,Str "like",Space,Str "this:",Space,Str "Fig.\160\&1.1",Str "."]+ ,Para [Str "It\8217s",Space,Str "possible",Space,Str "to",Space,Str "capitalize",Space,Str "reference",Space,Str "prefixes,",Space,Str "like",Space,Str "this:",Space,Str "Fig.\160\&1.1."] ,Para [Str "In",Space,Str "case",Space,Str "of",Space,Str "multiple",Space,Str "references,",Space,Str "capitalization",Space,Str "is",Space,Str "determined",Space,Str "by",Space,Str "first",Space,Str "reference.",Space,Str "Figs.\160\&1.1,",Space,Str "1.2",Space,Str "is",Space,Str "capitalized,",Space,Str "while",Space,Str "figs.\160\&1.1,",Space,Str "1.2",Space,Str "is",Space,Str "not."]- ,Para [Str "It",Space,Str "is",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "mix",Space,Str "different",Space,Str "references,",Space,Str "like",Space,Str "fig.\160\&1.1",Str ",",Space,Str "tbl.\160\&3.1",Str ",",Space,Str "lsts.\160\&4.1,",Space,Str "4.2",Str ",",Space,Str "figs.\160\&1.2,",Space,Str "1.3",Str ",",Space,Str "which",Space,Str "will",Space,Str "be",Space,Str "grouped",Space,Str "in",Space,Str "order",Space,Str "they",Space,Str "are",Space,Str "specified.",Space,Str "You",Space,Str "can",Space,Str "even",Space,Str "intermix",Space,Str "this",Space,Str "with",Space,Str "regular",Space,Str "citations,",Space,Str "although",Space,Str "it's",Space,Str "not",Space,Str "recommended:",Space,Str "fig.\160\&1.1",Str ",",Space,Str "tbl.\160\&3.1",Str ",",Space,Cite [Citation {citationId = "unprocessedCitation", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@unprocessedCitation]"]]+ ,Para [Str "It",Space,Str "is",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "mix",Space,Str "different",Space,Str "references,",Space,Str "like",Space,Str "fig.\160\&1.1,",Space,Str "tbl.\160\&3.1,",Space,Str "lsts.\160\&4.1,",Space,Str "4.2,",Space,Str "figs.\160\&1.2,",Space,Str "1.3,",Space,Str "which",Space,Str "will",Space,Str "be",Space,Str "grouped",Space,Str "in",Space,Str "order",Space,Str "they",Space,Str "are",Space,Str "specified.",Space,Str "You",Space,Str "can",Space,Str "even",Space,Str "intermix",Space,Str "this",Space,Str "with",Space,Str "regular",Space,Str "citations,",Space,Str "although",Space,Str "it\8217s",Space,Str "not",Space,Str "recommended:",Space,Str "fig.\160\&1.1,",Space,Str "tbl.\160\&3.1,",Space,Cite [Citation {citationId = "unprocessedCitation", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@unprocessedCitation]"]] ,Para [Str "You",Space,Str "can",Space,Str "also",Space,Str "have",Space,Str "custom",Space,Str "chapter",Space,Str "reference",Space,Str "labels,",Space,Str "like",Space,Str "sec.\160AppA.CustLab"] ,Para [Str "Subfigures",Space,Str "are",Space,Str "supported,",Space,Str "see",Space,Str "figs.\160\&1.4,",Space,Str "1.4",Space,Str "(b)"] ,Header 1 ("sec:sec1",[],[]) [Str "Chapter",Space,Str "1.",Space,Str "Figures"]@@ -44,7 +44,7 @@ ,Div ("lst:captionAttr",["listing","haskell"],[]) [Para [Str "Listing",Space,Str "4.1:",Space,Str "Listing",Space,Str "caption"] ,CodeBlock ("",["haskell"],[]) "main :: IO ()\nmain = putStrLn \"Hello World!\""]- ,Para [RawInline (Format "tex") "\\pagebreak"]+ ,RawBlock (Format "latex") "\\pagebreak" ,Header 2 ("sec:table-capts",[],[]) [Str "Table-style",Space,Str "captions"] ,Para [Str "Enabled",Space,Str "with",Space,Code ("",[],[]) "codeBlockCaptions",Space,Str "metadata",Space,Str "option.",Space,Str "If",Space,Str "code",Space,Str "block",Space,Str "is",Space,Str "immediately",SoftBreak,Str "adjacent",Space,Str "to",Space,Str "paragraph,",Space,Str "starting",Space,Str "with",Space,Code ("",[],[]) "Listing:",Space,Str "or",Space,Code ("",[],[]) ":",Str ",",Space,Str "said",Space,Str "paragraph",Space,Str "will",Space,Str "be",SoftBreak,Str "treated",Space,Str "as",Space,Str "code",Space,Str "block",Space,Str "caption."] ,Div ("lst:tableCaption",["listing","haskell"],[])@@ -56,25 +56,25 @@ [Para [Str "Listing",Space,Str "4.3:",Space,Str "Listing",Space,Str "caption"] ,CodeBlock ("",["haskell"],[]) "main :: IO ()\nmain = putStrLn \"Hello World!\""] ,Header 1 ("sec:unnumbered-chapter.",["unnumbered"],[]) [Str "Unnumbered",Space,Str "chapter."]- ,Para [Str "This",Space,Str "chapter",Space,Str "doesn't",Space,Str "change",Space,Str "chapter",Space,Str "prefix",Space,Str "of",Space,Str "referenced",Space,Str "elements,",Space,Str "instead",Space,Str "keeping",Space,Str "number",Space,Str "of",Space,Str "previous",Space,Str "chapter,",Space,Str "e.g.",SoftBreak,Span ("eq:eqn2",[],[]) [Math DisplayMath " S(x) = \\int_{x_1}^{x_2} a x+b \\ \\mathrm{d}x \\qquad(4.1)"]]+ ,Para [Str "This",Space,Str "chapter",Space,Str "doesn\8217t",Space,Str "change",Space,Str "chapter",Space,Str "prefix",Space,Str "of",Space,Str "referenced",Space,Str "elements,",Space,Str "instead",Space,Str "keeping",Space,Str "number",Space,Str "of",Space,Str "previous",Space,Str "chapter,",Space,Str "e.g.",SoftBreak,Span ("eq:eqn2",[],[]) [Math DisplayMath " S(x) = \\int_{x_1}^{x_2} a x+b \\ \\mathrm{d}x \\qquad(4.1)"]] ,Header 1 ("sec:chapter-5.-reference-lists",[],[]) [Str "Chapter",Space,Str "5.",Space,Str "Reference",Space,Str "lists"]- ,Para [Str "It's",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "show",Space,Str "lists",Space,Str "of",Space,Str "figures",Space,Str "and",Space,Str "tables,",Space,Str "like",Space,Str "this:"]+ ,Para [Str "It\8217s",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "show",Space,Str "lists",Space,Str "of",Space,Str "figures",Space,Str "and",Space,Str "tables,",Space,Str "like",Space,Str "this:"] ,Header 2 ("list-of-figures",[],[]) [Str "List",Space,Str "of",Space,Str "Figures"] ,Div ("",["list"],[]) [Para [Str "1",Space,Str "A",Space,Str "figure"]- ,Para [Str "1",Str ".",Str "1",Space,Str "First",Space,Str "figure"]- ,Para [Str "1",Str ".",Str "2",Space,Str "Second",Space,Str "figure"]- ,Para [Str "1",Str ".",Str "3",Space,Str "Third",Space,Str "figure"]- ,Para [Str "1",Str ".",Str "4",Space,Str "Subfigure",Space,Str "a"]- ,Para [Str "1",Str ".",Str "4",Space,Str "Subfigure",Space,Str "b"]- ,Para [Str "1",Str ".",Str "4",Space,Str "Subfigures",Space,Str "caption"]]+ ,Para [Str "1.1",Space,Str "First",Space,Str "figure"]+ ,Para [Str "1.2",Space,Str "Second",Space,Str "figure"]+ ,Para [Str "1.3",Space,Str "Third",Space,Str "figure"]+ ,Para [Str "1.4",Space,Str "Subfigure",Space,Str "a"]+ ,Para [Str "1.4",Space,Str "Subfigure",Space,Str "b"]+ ,Para [Str "1.4",Space,Str "Subfigures",Space,Str "caption"]] ,Header 2 ("list-of-tables",[],[]) [Str "List",Space,Str "of",Space,Str "Tables"] ,Div ("",["list"],[])- [Para [Str "3",Str ".",Str "1",Space,Str "Table",Space,Str "example"]]+ [Para [Str "3.1",Space,Str "Table",Space,Str "example"]] ,Header 1 ("",[],[]) [Str "List",Space,Str "of",Space,Str "Listings"] ,Div ("",["list"],[])- [Para [Str "4",Str ".",Str "1",Space,Str "Listing",Space,Str "caption"]- ,Para [Str "4",Str ".",Str "2",Space,Str "Listing",Space,Str "caption"]- ,Para [Str "4",Str ".",Str "3",Space,Str "Listing",Space,Str "caption"]]+ [Para [Str "4.1",Space,Str "Listing",Space,Str "caption"]+ ,Para [Str "4.2",Space,Str "Listing",Space,Str "caption"]+ ,Para [Str "4.3",Space,Str "Listing",Space,Str "caption"]] ,Header 1 ("sec:appendix-a.-custom-labels",[],[("label","AppA")]) [Str "Appendix",Space,Str "A.",Space,Str "Custom",Space,Str "labels"] ,Header 2 ("sec:custlabs",[],[("label","CustLab")]) [Str "This",Space,Str "section",Space,Str "will",Space,Str "have",Space,Str "custom",Space,Str "label"]]
test/demo.inc view
@@ -1,10 +1,10 @@- [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "demo",Space,Str "file",Space,Str "for",Space,Str "pandoc-crossref.",Space,Str "With",Space,Str "this",Space,Str "filter,",Space,Str "you",Space,Str "can",Space,Str "cross-reference",Space,Str "figures",Space,Str "(see",Space,Str "figs.\160\&2-4",Str "),",Space,Str "display",Space,Str "equations",Space,Str "(see",Space,Str "eq.\160\&1",Str "),",Space,Str "tables",Space,Str "(see",Space,Str "tbl.\160\&1",Str ")",Space,Str "and",Space,Str "sections",Space,Str "(",Str "secs.\160\&1,",Space,Str "2,",Space,Str "4.1-4.3",Str ")"]+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "demo",Space,Str "file",Space,Str "for",Space,Str "pandoc-crossref.",Space,Str "With",Space,Str "this",Space,Str "filter,",Space,Str "you",Space,Str "can",Space,Str "cross-reference",Space,Str "figures",Space,Str "(see",Space,Str "figs.\160\&2-4),",Space,Str "display",Space,Str "equations",Space,Str "(see",Space,Str "eq.\160\&1),",Space,Str "tables",Space,Str "(see",Space,Str "tbl.\160\&1)",Space,Str "and",Space,Str "sections",Space,Str "(",Str "secs.\160\&1,",Space,Str "2,",Space,Str "4.1-4.3)"] ,Para [Str "For",Space,Str "immediate",Space,Str "example,",Space,Str "see",Space,Str "fig.\160\&1"] ,Para [Image ("fig:figure0",[],[]) [Str "Figure",Space,Str "#",Space,Str "1:",Space,Str "A",Space,Str "figure"] ("img1.jpg","fig:")] ,Para [Str "There",Space,Str "is",Space,Str "also",Space,Str "support",Space,Str "for",Space,Str "code",Space,Str "blocks,",Space,Str "for",Space,Str "example,",Space,Str "lsts.\160\&1-3"]- ,Para [Str "It's",Space,Str "possible",Space,Str "to",Space,Str "capitalize",Space,Str "reference",Space,Str "prefixes,",Space,Str "like",Space,Str "this:",Space,Str "Fig.\160\&2",Str "."]+ ,Para [Str "It\8217s",Space,Str "possible",Space,Str "to",Space,Str "capitalize",Space,Str "reference",Space,Str "prefixes,",Space,Str "like",Space,Str "this:",Space,Str "Fig.\160\&2."] ,Para [Str "In",Space,Str "case",Space,Str "of",Space,Str "multiple",Space,Str "references,",Space,Str "capitalization",Space,Str "is",Space,Str "determined",Space,Str "by",Space,Str "first",Space,Str "reference.",Space,Str "Figs.\160\&2,",Space,Str "3",Space,Str "is",Space,Str "capitalized,",Space,Str "while",Space,Str "figs.\160\&2,",Space,Str "3",Space,Str "is",Space,Str "not."]- ,Para [Str "It",Space,Str "is",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "mix",Space,Str "different",Space,Str "references,",Space,Str "like",Space,Str "fig.\160\&2",Str ",",Space,Str "tbl.\160\&1",Str ",",Space,Str "lsts.\160\&1,",Space,Str "2",Str ",",Space,Str "figs.\160\&3,",Space,Str "4",Str ",",Space,Str "which",Space,Str "will",Space,Str "be",Space,Str "grouped",Space,Str "in",Space,Str "order",Space,Str "they",Space,Str "are",Space,Str "specified.",Space,Str "You",Space,Str "can",Space,Str "even",Space,Str "intermix",Space,Str "this",Space,Str "with",Space,Str "regular",Space,Str "citations,",Space,Str "although",Space,Str "it's",Space,Str "not",Space,Str "recommended:",Space,Str "fig.\160\&2",Str ",",Space,Str "tbl.\160\&1",Str ",",Space,Cite [Citation {citationId = "unprocessedCitation", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@unprocessedCitation]"]]+ ,Para [Str "It",Space,Str "is",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "mix",Space,Str "different",Space,Str "references,",Space,Str "like",Space,Str "fig.\160\&2,",Space,Str "tbl.\160\&1,",Space,Str "lsts.\160\&1,",Space,Str "2,",Space,Str "figs.\160\&3,",Space,Str "4,",Space,Str "which",Space,Str "will",Space,Str "be",Space,Str "grouped",Space,Str "in",Space,Str "order",Space,Str "they",Space,Str "are",Space,Str "specified.",Space,Str "You",Space,Str "can",Space,Str "even",Space,Str "intermix",Space,Str "this",Space,Str "with",Space,Str "regular",Space,Str "citations,",Space,Str "although",Space,Str "it\8217s",Space,Str "not",Space,Str "recommended:",Space,Str "fig.\160\&2,",Space,Str "tbl.\160\&1,",Space,Cite [Citation {citationId = "unprocessedCitation", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@unprocessedCitation]"]] ,Para [Str "You",Space,Str "can",Space,Str "also",Space,Str "have",Space,Str "custom",Space,Str "chapter",Space,Str "reference",Space,Str "labels,",Space,Str "like",Space,Str "sec.\160AppA.CustLab"] ,Para [Str "Subfigures",Space,Str "are",Space,Str "supported,",Space,Str "see",Space,Str "figs.\160\&5,",Space,Str "5",Space,Str "(b)"] ,Header 1 ("sec:sec1",[],[]) [Str "Chapter",Space,Str "1.",Space,Str "Figures"]@@ -44,7 +44,7 @@ ,Div ("lst:captionAttr",["listing","haskell"],[]) [Para [Str "Listing",Space,Str "1:",Space,Str "Listing",Space,Str "caption"] ,CodeBlock ("",["haskell"],[]) "main :: IO ()\nmain = putStrLn \"Hello World!\""]- ,Para [RawInline (Format "tex") "\\pagebreak"]+ ,RawBlock (Format "latex") "\\pagebreak" ,Header 2 ("sec:table-capts",[],[]) [Str "Table-style",Space,Str "captions"] ,Para [Str "Enabled",Space,Str "with",Space,Code ("",[],[]) "codeBlockCaptions",Space,Str "metadata",Space,Str "option.",Space,Str "If",Space,Str "code",Space,Str "block",Space,Str "is",Space,Str "immediately",SoftBreak,Str "adjacent",Space,Str "to",Space,Str "paragraph,",Space,Str "starting",Space,Str "with",Space,Code ("",[],[]) "Listing:",Space,Str "or",Space,Code ("",[],[]) ":",Str ",",Space,Str "said",Space,Str "paragraph",Space,Str "will",Space,Str "be",SoftBreak,Str "treated",Space,Str "as",Space,Str "code",Space,Str "block",Space,Str "caption."] ,Div ("lst:tableCaption",["listing","haskell"],[])@@ -56,9 +56,9 @@ [Para [Str "Listing",Space,Str "3:",Space,Str "Listing",Space,Str "caption"] ,CodeBlock ("",["haskell"],[]) "main :: IO ()\nmain = putStrLn \"Hello World!\""] ,Header 1 ("sec:unnumbered-chapter.",["unnumbered"],[]) [Str "Unnumbered",Space,Str "chapter."]- ,Para [Str "This",Space,Str "chapter",Space,Str "doesn't",Space,Str "change",Space,Str "chapter",Space,Str "prefix",Space,Str "of",Space,Str "referenced",Space,Str "elements,",Space,Str "instead",Space,Str "keeping",Space,Str "number",Space,Str "of",Space,Str "previous",Space,Str "chapter,",Space,Str "e.g.",SoftBreak,Span ("eq:eqn2",[],[]) [Math DisplayMath " S(x) = \\int_{x_1}^{x_2} a x+b \\ \\mathrm{d}x \\qquad(3)"]]+ ,Para [Str "This",Space,Str "chapter",Space,Str "doesn\8217t",Space,Str "change",Space,Str "chapter",Space,Str "prefix",Space,Str "of",Space,Str "referenced",Space,Str "elements,",Space,Str "instead",Space,Str "keeping",Space,Str "number",Space,Str "of",Space,Str "previous",Space,Str "chapter,",Space,Str "e.g.",SoftBreak,Span ("eq:eqn2",[],[]) [Math DisplayMath " S(x) = \\int_{x_1}^{x_2} a x+b \\ \\mathrm{d}x \\qquad(3)"]] ,Header 1 ("sec:chapter-5.-reference-lists",[],[]) [Str "Chapter",Space,Str "5.",Space,Str "Reference",Space,Str "lists"]- ,Para [Str "It's",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "show",Space,Str "lists",Space,Str "of",Space,Str "figures",Space,Str "and",Space,Str "tables,",Space,Str "like",Space,Str "this:"]+ ,Para [Str "It\8217s",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "show",Space,Str "lists",Space,Str "of",Space,Str "figures",Space,Str "and",Space,Str "tables,",Space,Str "like",Space,Str "this:"] ,Header 2 ("list-of-figures",[],[]) [Str "List",Space,Str "of",Space,Str "Figures"] ,OrderedList (1,DefaultStyle,DefaultDelim) [[Plain [Str "A",Space,Str "figure"]]
test/m2m/equations-auto/expect.md view
@@ -1,16 +1,16 @@ This is a test file with some referenced equations, line-[$$ this \qquad(1)$$]{}+$$ this \qquad(1)$$ -Some equations might be inside of text, [$$ for example \qquad(2)$$]{}-this one.+Some equations might be inside of text, $$ for example \qquad(2)$$ this+one. Some equations might be on start of paragraphs: -[$$ start \qquad(3)$$]{} of paragraph.+$$ start \qquad(3)$$ of paragraph. Other might be on separate paragraphs of their own: -[$$ separate \qquad(4)$$]{}+$$ separate \qquad(4)$$ Some of those can be labelled:
test/m2m/equations-tables-auto/expect.md view
@@ -2,9 +2,9 @@ <div> - ------------------------------------------------------------------------------------------------------------------------ ------------- $$ this $$ $$(1)$$- ------------------------------------------------------------------------------------------------------------------------ ------------+ ---------------------------------------------------------------- ---------+ $$ this $$ $$(1)$$+ ---------------------------------------------------------------- --------- </div> @@ -12,9 +12,9 @@ <div> - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------- $$ for example $$ $$(2)$$- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------+ ---------------------------------------------------------------- ---------+ $$ for example $$ $$(2)$$+ ---------------------------------------------------------------- --------- </div> @@ -24,9 +24,9 @@ <div> - ---------------------------------------------------------------------------------------------------------------------------------- -------------- $$ start $$ $$(3)$$- ---------------------------------------------------------------------------------------------------------------------------------- -------------+ ---------------------------------------------------------------- ---------+ $$ start $$ $$(3)$$+ ---------------------------------------------------------------- --------- </div> @@ -36,9 +36,9 @@ <div> - ---------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------- $$ separate $$ $$(4)$$- ---------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------+ ---------------------------------------------------------------- ---------+ $$ separate $$ $$(4)$$+ ---------------------------------------------------------------- --------- </div> @@ -46,47 +46,39 @@ This is a test file with some referenced equations, line -<div id="eq:0">-- ------------------------------------------------------------------------------------------------------------------------ ------------- $$ this $$ $$(5)$$- ------------------------------------------------------------------------------------------------------------------------ --------------</div>+::: {#eq:0}+ ---------------------------------------------------------------- ---------+ $$ this $$ $$(5)$$+ ---------------------------------------------------------------- ---------+::: Some equations might be inside of text, -<div id="eq:1">-- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------- $$ for example $$ $$(6)$$- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------</div>+::: {#eq:1}+ ---------------------------------------------------------------- ---------+ $$ for example $$ $$(6)$$+ ---------------------------------------------------------------- ---------+::: this one. Some equations might be on start of paragraphs: -<div id="eq:2">-- ---------------------------------------------------------------------------------------------------------------------------------- -------------- $$ start $$ $$(7)$$- ---------------------------------------------------------------------------------------------------------------------------------- ---------------</div>+::: {#eq:2}+ ---------------------------------------------------------------- ---------+ $$ start $$ $$(7)$$+ ---------------------------------------------------------------- ---------+::: of paragraph. Other might be on separate paragraphs of their own: -<div id="eq:3">-- ---------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------- $$ separate $$ $$(8)$$- ---------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------</div>+::: {#eq:3}+ ---------------------------------------------------------------- ---------+ $$ separate $$ $$(8)$$+ ---------------------------------------------------------------- ---------+::: Then they can be referenced:
test/m2m/equations-tables/expect.md view
@@ -14,47 +14,39 @@ This is a test file with some referenced equations, line -<div id="eq:0">-- ------------------------------------------------------------------------------------------------------------------------ ------------- $$ this $$ $$(1)$$- ------------------------------------------------------------------------------------------------------------------------ --------------</div>+::: {#eq:0}+ ---------------------------------------------------------------- ---------+ $$ this $$ $$(1)$$+ ---------------------------------------------------------------- ---------+::: Some equations might be inside of text, -<div id="eq:1">-- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------- $$ for example $$ $$(2)$$- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------</div>+::: {#eq:1}+ ---------------------------------------------------------------- ---------+ $$ for example $$ $$(2)$$+ ---------------------------------------------------------------- ---------+::: this one. Some equations might be on start of paragraphs: -<div id="eq:2">-- ---------------------------------------------------------------------------------------------------------------------------------- -------------- $$ start $$ $$(3)$$- ---------------------------------------------------------------------------------------------------------------------------------- ---------------</div>+::: {#eq:2}+ ---------------------------------------------------------------- ---------+ $$ start $$ $$(3)$$+ ---------------------------------------------------------------- ---------+::: of paragraph. Other might be on separate paragraphs of their own: -<div id="eq:3">-- ---------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------- $$ separate $$ $$(4)$$- ---------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------</div>+::: {#eq:3}+ ---------------------------------------------------------------- ---------+ $$ separate $$ $$(4)$$+ ---------------------------------------------------------------- ---------+::: Then they can be referenced:
test/m2m/listing-captions-ids/expect.md view
@@ -1,48 +1,40 @@ After code block -<div id="lst:code1" class="listing haskell">-+::: {#lst:code1 .listing .haskell} Listing 1: Listing caption 1 ``` {.haskell} main :: IO () main = putStrLn "Hello World!" ```--</div>--<div id="lst:code2" class="listing haskell">+::: +::: {#lst:code2 .listing .haskell} Listing 2: Listing caption 2 ``` {.haskell} main :: IO () main = putStrLn "Hello World!" ```--</div>--<div id="lst:code3" class="listing haskell">+::: +::: {#lst:code3 .listing .haskell} Listing 3: Listing caption 3 ``` {.haskell} main :: IO () main = putStrLn "Hello World!" ```--</div>--<div id="lst:code4" class="listing haskell">+::: +::: {#lst:code4 .listing .haskell} Listing 4: Listing caption 4 ``` {.haskell} main :: IO () main = putStrLn "Hello World!" ```--</div>+::: ``` {.haskell} main :: IO ()@@ -60,49 +52,41 @@ Before code block -<div id="lst:code11" class="listing haskell">-+::: {#lst:code11 .listing .haskell} Listing 5: Listing caption 11 ``` {.haskell} main :: IO () main = putStrLn "Hello World!" ```--</div>--<div id="lst:code12" class="listing haskell">+::: +::: {#lst:code12 .listing .haskell} Listing 6: Listing caption 12 ``` {.haskell} main :: IO () main = putStrLn "Hello World!" ```--</div>--<div id="lst:code13" class="listing haskell">+::: +::: {#lst:code13 .listing .haskell} Listing 7: Listing caption 13 ``` {.haskell} main :: IO () main = putStrLn "Hello World!" ```--</div>--<div id="lst:code14" class="listing haskell">+::: +::: {#lst:code14 .listing .haskell} Listing 8: Listing caption 14 ``` {.haskell} main :: IO () main = putStrLn "Hello World!" ```--</div>+::: ------------------------------------------------------------------------
test/m2m/listing-captions-ids/expect.tex view
@@ -4,7 +4,8 @@ \caption{Listing caption 1} -\hypertarget{lst:code1}{\label{lst:code1}}+\hypertarget{lst:code1}{%+\label{lst:code1}}% \begin{Shaded} \begin{Highlighting}[] \OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}@@ -18,7 +19,8 @@ \caption{Listing caption 2} -\hypertarget{lst:code2}{\label{lst:code2}}+\hypertarget{lst:code2}{%+\label{lst:code2}}% \begin{Shaded} \begin{Highlighting}[] \OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}@@ -32,7 +34,8 @@ \caption{Listing caption 3} -\hypertarget{lst:code3}{\label{lst:code3}}+\hypertarget{lst:code3}{%+\label{lst:code3}}% \begin{Shaded} \begin{Highlighting}[] \OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}@@ -46,7 +49,8 @@ \caption{Listing caption 4} -\hypertarget{lst:code4}{\label{lst:code4}}+\hypertarget{lst:code4}{%+\label{lst:code4}}% \begin{Shaded} \begin{Highlighting}[] \OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}@@ -80,7 +84,8 @@ \caption{Listing caption 11} -\hypertarget{lst:code11}{\label{lst:code11}}+\hypertarget{lst:code11}{%+\label{lst:code11}}% \begin{Shaded} \begin{Highlighting}[] \OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}@@ -94,7 +99,8 @@ \caption{Listing caption 12} -\hypertarget{lst:code12}{\label{lst:code12}}+\hypertarget{lst:code12}{%+\label{lst:code12}}% \begin{Shaded} \begin{Highlighting}[] \OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}@@ -108,7 +114,8 @@ \caption{Listing caption 13} -\hypertarget{lst:code13}{\label{lst:code13}}+\hypertarget{lst:code13}{%+\label{lst:code13}}% \begin{Shaded} \begin{Highlighting}[] \OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}@@ -122,7 +129,8 @@ \caption{Listing caption 14} -\hypertarget{lst:code14}{\label{lst:code14}}+\hypertarget{lst:code14}{%+\label{lst:code14}}% \begin{Shaded} \begin{Highlighting}[] \OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}@@ -151,3 +159,4 @@ \NormalTok{main }\FunctionTok{=}\NormalTok{ putStrLn }\StringTok{"Hello World!"} \end{Highlighting} \end{Shaded}+
test/m2m/subfigures-ccsDelim/expect.md view
@@ -1,7 +1,6 @@ You can define subfigures: -<div id="fig:subfigures" class="subfigures">-+::: {#fig:subfigures .subfigures} {#fig:subfig1} {#fig:subfig2}  @@ -11,13 +10,11 @@ {#fig:subfig7}  {#fig:subfig9} -Figure 1: Caption. a — 1; b — 2; c — 3; d — 4; e — 5; f — 6; g — 7; h —-8; i — 9--</div>--<div id="fig:subfigures2" class="subfigures">+Figure 1: Caption. a --- 1; b --- 2; c --- 3; d --- 4; e --- 5; f ---+6; g --- 7; h --- 8; i --- 9+::: +::: {#fig:subfigures2 .subfigures} {#fig:subfig21} {#fig:subfig22}@@ -36,10 +33,9 @@ {#fig:subfig29} -Figure 2: Caption. a — 1; b — 2; c — 3; d — 4; e — 5; f — 6; g — 7; h —-8; i — 9--</div>+Figure 2: Caption. a --- 1; b --- 2; c --- 3; d --- 4; e --- 5; f ---+6; g --- 7; h --- 8; i --- 9+::: Figures themselves can be referenced fig. 2, as well as individual subfigures: figs. 1 (a), 1 (b), 2 (i)
test/m2m/subfigures-grid/expect.md view
@@ -1,7 +1,6 @@ You can define subfigures: -<div id="fig:subfigures" class="subfigures">-+::: {#fig:subfigures .subfigures} +:------------------:+:------------------:+:------------------:+ | {#fi | {#fi | {wid | | g:subfig1 | g:subfig2 | th="100%"} |@@ -16,13 +15,11 @@ | width="100%"} | | width="100%"} | +--------------------+--------------------+--------------------+ -Figure 1: Caption. a — 1, b — 2, c — 3, d — 4, e — 5, f — 6, g — 7, h —-8, i — 9--</div>--<div id="fig:subfigures2" class="subfigures">+Figure 1: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,+g --- 7, h --- 8, i --- 9+::: +::: {#fig:subfigures2 .subfigures} +:--------------------------------------------------------------------:+ | {#fig:subfig21 width="100%"} | +----------------------------------------------------------------------+@@ -43,10 +40,9 @@ | {#fig:subfig29 width="100%"} | +----------------------------------------------------------------------+ -Figure 2: Caption. a — 1, b — 2, c — 3, d — 4, e — 5, f — 6, g — 7, h —-8, i — 9--</div>+Figure 2: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,+g --- 7, h --- 8, i --- 9+::: Figures themselves can be referenced fig. 2, as well as individual subfigures: figs. 1 (a), 1 (b), 2 (i)
test/m2m/subfigures-grid/expect.tex view
@@ -3,17 +3,17 @@ \begin{figure} \centering -\subfloat[1]{\includegraphics[width=0.30000\textwidth]{fig1.png}\label{fig:subfig1}}-\subfloat[2]{\includegraphics[width=0.30000\textwidth]{fig2.png}\label{fig:subfig2}}-\subfloat[3]{\includegraphics[width=0.30000\textwidth]{fig3.png}}+\subfloat[1]{\includegraphics[width=0.3\textwidth]{fig1.png}\label{fig:subfig1}}+\subfloat[2]{\includegraphics[width=0.3\textwidth]{fig2.png}\label{fig:subfig2}}+\subfloat[3]{\includegraphics[width=0.3\textwidth]{fig3.png}} -\subfloat[4]{\includegraphics[width=0.30000\textwidth]{fig4.png}\label{fig:subfig4}}-\subfloat[5]{\includegraphics[width=0.30000\textwidth]{fig5.png}}-\subfloat[6]{\includegraphics[width=0.30000\textwidth]{fig6.png}\label{fig:subfig6}}+\subfloat[4]{\includegraphics[width=0.3\textwidth]{fig4.png}\label{fig:subfig4}}+\subfloat[5]{\includegraphics[width=0.3\textwidth]{fig5.png}}+\subfloat[6]{\includegraphics[width=0.3\textwidth]{fig6.png}\label{fig:subfig6}} -\subfloat[7]{\includegraphics[width=0.30000\textwidth]{fig7.png}\label{fig:subfig7}}-\subfloat[8]{\includegraphics[width=0.30000\textwidth]{fig8.png}}-\subfloat[9]{\includegraphics[width=0.30000\textwidth]{fig9.png}\label{fig:subfig9}}+\subfloat[7]{\includegraphics[width=0.3\textwidth]{fig7.png}\label{fig:subfig7}}+\subfloat[8]{\includegraphics[width=0.3\textwidth]{fig8.png}}+\subfloat[9]{\includegraphics[width=0.3\textwidth]{fig9.png}\label{fig:subfig9}} \caption{Caption}
test/m2m/subfigures/expect.md view
@@ -1,7 +1,6 @@ You can define subfigures: -<div id="fig:subfigures" class="subfigures">-+::: {#fig:subfigures .subfigures} {#fig:subfig1} {#fig:subfig2}  @@ -11,13 +10,11 @@ {#fig:subfig7}  {#fig:subfig9} -Figure 1: Caption. a — 1, b — 2, c — 3, d — 4, e — 5, f — 6, g — 7, h —-8, i — 9--</div>--<div id="fig:subfigures2" class="subfigures">+Figure 1: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,+g --- 7, h --- 8, i --- 9+::: +::: {#fig:subfigures2 .subfigures} {#fig:subfig21} {#fig:subfig22}@@ -36,10 +33,9 @@ {#fig:subfig29} -Figure 2: Caption. a — 1, b — 2, c — 3, d — 4, e — 5, f — 6, g — 7, h —-8, i — 9--</div>+Figure 2: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,+g --- 7, h --- 8, i --- 9+::: Figures themselves can be referenced fig. 2, as well as individual subfigures: figs. 1 (a), 1 (b), 2 (i)
test/test-integrative.hs view
@@ -1,15 +1,34 @@+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}+ {-# LANGUAGE CPP #-} import Test.Hspec-import Text.Pandoc+import Text.Pandoc hiding (runIO)+import qualified Text.Pandoc as P (runIO) import Text.Pandoc.CrossRef import System.FilePath import System.Directory import Control.Monad--lines' :: String -> [(Integer, String)]-lines' = zip [1..] . lines+import Text.Pandoc.Highlighting+import qualified Data.Text as T --- m2m :: Meta -> String -> String -> Expectation m2m :: String -> Spec m2m dir | dir == "." = return ()@@ -19,15 +38,20 @@ input <- runIO $ readFile ("test" </> "m2m" </> dir </> "input.md") expect_md <- runIO $ readFile ("test" </> "m2m" </> dir </> "expect.md") expect_tex <- runIO $ readFile ("test" </> "m2m" </> dir </> "expect.tex")- p@(Pandoc meta _) <- either (fail . show) return $ readMarkdown def input- let actual_md = writeMarkdown def $ runCrossRef meta (Just $ Format "markdown") defaultCrossRefAction p- actual_tex = writeLaTeX def{writerHighlight=True} $ runCrossRef meta (Just $ Format "latex") defaultCrossRefAction p+ let ro = def { readerExtensions = pandocExtensions }+ wo = def { writerExtensions = pandocExtensions, writerHighlightStyle=Just pygments }+ p@(Pandoc meta _) <- runIO $ either (error . show) id <$> P.runIO (readMarkdown ro $ T.pack input)+ let actual_md = either (fail . show) T.unpack $ runPure $ writeMarkdown wo $ runCrossRef meta (Just $ Format "markdown") defaultCrossRefAction p+ actual_tex = either (fail . show) T.unpack $ runPure $ writeLaTeX wo $ runCrossRef meta (Just $ Format "latex") defaultCrossRefAction p it "Markdown" $ do zipWithM_ shouldBe (lines' actual_md) (lines' expect_md)- length (lines' actual_md) `shouldBe` length (lines' expect_md)+ length' (lines' actual_md) `shouldBe` length' (lines' expect_md) it "LaTeX" $ do zipWithM_ shouldBe (lines' actual_tex) (lines' expect_tex)- length (lines' actual_tex) `shouldBe` length (lines' expect_tex)+ length' (lines' actual_tex) `shouldBe` length' (lines' expect_tex)+ where+ lines' = zip [(1 :: Int)..] . lines+ length' = length . filter (not . null . snd) main :: IO () main = do
test/test-pandoc-crossref.hs view
@@ -1,20 +1,39 @@-{-# LANGUAGE FlexibleContexts, CPP #-}+{-+pandoc-crossref is a pandoc filter for numbering figures,+equations, tables and cross-references to them.+Copyright (C) 2015 Nikolay Yakimov <root@livid.pp.ru>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License along+with this program; if not, write to the Free Software Foundation, Inc.,+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+-}++{-# LANGUAGE FlexibleContexts #-} import Test.Hspec-import Text.Pandoc hiding (readMarkdown)+import Text.Pandoc hiding (getDataFileName) import Text.Pandoc.Builder import Control.Monad.State import Data.List import Control.Arrow import Data.Monoid -- needed for ghc<7.10 import qualified Data.Map as M+import qualified Data.Text as T import qualified Data.Default as Df import Text.Pandoc.CrossRef import Text.Pandoc.CrossRef.Util.Options-import Text.Pandoc.CrossRef.Util.Gap import Text.Pandoc.CrossRef.Util.Util import Text.Pandoc.CrossRef.References.Types-import Text.Pandoc.CrossRef.Util.Settings import Data.Accessor hiding ((=:)) import qualified Text.Pandoc.CrossRef.References.Blocks as References.Blocks import qualified Text.Pandoc.CrossRef.References.Refs as References.Refs@@ -216,11 +235,11 @@ describe "References.List.listOf" $ do it "Generates list of tables" $- testList (para $ rawInline "tex" "\\listoftables")+ testList (rawBlock "latex" "\\listoftables") (tblRefs =: M.fromList $ refRec' "tbl:1" 4 "4" <> refRec' "tbl:2" 5 "5" <> refRec' "tbl:3" 6 "6") (header 1 (text "List of Tables") <> orderedList ((plain . str . show) `map` [4..6 :: Int])) it "Generates list of figures" $- testList (para $ rawInline "tex" "\\listoffigures")+ testList (rawBlock "latex" "\\listoffigures") (imgRefs =: M.fromList $ refRec' "fig:1" 4 "4" <> refRec' "fig:2" 5 "5" <> refRec' "fig:3" 6 "6") (header 1 (text "List of Figures") <> orderedList ((plain . str . show) `map` [4..6 :: Int])) @@ -256,36 +275,33 @@ describe "Test files" $ do it "demo.md matches demo.native" $ do- demomd <- readFile =<< getDataFileName "demo.md"- let Pandoc m b = readMarkdown def demomd+ demomd <- readFile =<< getDataFileName "docs/demo/demo.md"+ Pandoc m b <- handleError $ runPure $ readMarkdown def {readerExtensions = pandocExtensions} $ T.pack demomd runCrossRef m Nothing crossRefBlocks b `shouldBe` Native.demo it "demo.md with chapters matches demo-chapters.native" $ do- demomd <- readFile =<< getDataFileName "demo.md"- let Pandoc m b = readMarkdown def demomd- m' = setMeta "chapters" True m+ demomd <- readFile =<< getDataFileName "docs/demo/demo.md"+ Pandoc m b <- handleError $ runPure $ readMarkdown def {readerExtensions = pandocExtensions} $ T.pack demomd+ let m' = setMeta "chapters" True m runCrossRef m' Nothing crossRefBlocks b `shouldBe` Native.demochapters describe "LaTeX" $ do let test = test' nullMeta infixr 5 `test`- test' m i o = writeLaTeX def (Pandoc m $ runCrossRef m (Just $ Format "latex") crossRefBlocks (toList i)) `shouldBe` o+ test' m i o = getLatex m i `shouldBe` o+ getLatex m i = either (fail . show) T.unpack (runPure $ writeLaTeX def (Pandoc m $ runCrossRef m (Just $ Format "latex") crossRefBlocks (toList i))) describe "Labels" $ do it "Section labels" $ headerWith ("sec:section_label1", [], []) 1 (text "Section") <> para (citeGen "sec:section_label" [1])- `test` "\\section{Section}\\label{sec:section_label1}\n\nsec.~\\ref{sec:section_label1}"+ `test` "\\hypertarget{sec:section_label1}{%\n\\section{Section}\\label{sec:section_label1}}\n\nsec.~\\ref{sec:section_label1}" it "Image labels" $ figure "img.png" [] "Title" "figure_label1" <> para (citeGen "fig:figure_label" [1])-#if MIN_VERSION_pandoc(1,18,0)- `test` "\\begin{figure}\n\\centering\n\\includegraphics{img.png}\n\\caption{Title}\\label{fig:figure_label1}\n\\end{figure}\n\nfig.~\\ref{fig:figure_label1}"-#else- `test` "\\begin{figure}[htbp]\n\\centering\n\\includegraphics{img.png}\n\\caption{Title}\\label{fig:figure_label1}\n\\end{figure}\n\nfig.~\\ref{fig:figure_label1}"-#endif+ `test` "\\hypertarget{fig:figure_label1}{%\n\\begin{figure}\n\\centering\n\\includegraphics{img.png}\n\\caption{Title}\\label{fig:figure_label1}\n\\end{figure}\n}\n\nfig.~\\ref{fig:figure_label1}" it "Eqn labels" $ equation "x^2" "some_equation1"@@ -295,17 +311,17 @@ it "Tbl labels" $ table' "A table" "some_table1" <> para (citeGen "tbl:some_table" [1])- `test` "\\hypertarget{tbl:some_table1}{}\n\\begin{longtable}[]{@{}@{}}\n\\caption{\\label{tbl:some_table1}A table }\\tabularnewline\n\\toprule\n\\tabularnewline\n\\midrule\n\\endfirsthead\n\\toprule\n\\tabularnewline\n\\midrule\n\\endhead\n\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\ntbl.~\\ref{tbl:some_table1}"+ `test` "\\hypertarget{tbl:some_table1}{}\n\\begin{longtable}[]{@{}@{}}\n\\caption{\\label{tbl:some_table1}A table}\\tabularnewline\n\\toprule\n\\tabularnewline\n\\midrule\n\\endfirsthead\n\\toprule\n\\tabularnewline\n\\midrule\n\\endhead\n\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\ntbl.~\\ref{tbl:some_table1}" it "Code block labels" $ do codeBlock' "A code block" "some_codeblock1" <> para (citeGen "lst:some_codeblock" [1])- `test` "\\begin{codelisting}\n\\caption{A code block}\n\n\\hypertarget{lst:some_codeblock1}{\\label{lst:some_codeblock1}}\n\\begin{verbatim}\nmain :: IO ()\n\\end{verbatim}\n\n\\end{codelisting}\n\nlst.~\\ref{lst:some_codeblock1}"+ `test` "\\begin{codelisting}\n\\caption{A code block}\n\n\\hypertarget{lst:some_codeblock1}{%\n\\label{lst:some_codeblock1}}%\n\\begin{Shaded}\n\\begin{Highlighting}[]\n\\OtherTok{main ::} \\DataTypeTok{IO}\\NormalTok{ ()}\n\\end{Highlighting}\n\\end{Shaded}\n\n\\end{codelisting}\n\nlst.~\\ref{lst:some_codeblock1}" let test1 = test' $ setMeta "codeBlockCaptions" True nullMeta infixr 5 `test1` codeBlockForTable "some_codeblock1" <> paraText ": A code block" <> para (citeGen "lst:some_codeblock" [1])- `test1` "\\begin{codelisting}\n\n\\caption{A code block}\n\n\\hypertarget{lst:some_codeblock1}{\\label{lst:some_codeblock1}}\n\\begin{verbatim}\nmain :: IO ()\n\\end{verbatim}\n\n\\end{codelisting}\n\nlst.~\\ref{lst:some_codeblock1}"+ `test1` "\\begin{codelisting}\n\n\\caption{A code block}\n\n\\hypertarget{lst:some_codeblock1}{%\n\\label{lst:some_codeblock1}}%\n\\begin{Shaded}\n\\begin{Highlighting}[]\n\\OtherTok{main ::} \\DataTypeTok{IO}\\NormalTok{ ()}\n\\end{Highlighting}\n\\end{Shaded}\n\n\\end{codelisting}\n\nlst.~\\ref{lst:some_codeblock1}" citeGen :: String -> [Int] -> Inlines citeGen p l = cite (mconcat $ map (cit . (p++) . show) l) $ text $