INÍCIO
This commit is contained in:
commit
9ceca45ccf
341 files changed
+73874
No files matched your search
Executable
+17
@@ -0,0 +1,17 @@
|
||||
title: Moan-livro
|
||||
author: Rafael Tavares Juliani
|
||||
version: 1.0.0
|
||||
quarto-required: ">=1.4.0"
|
||||
lang: pt-BR
|
||||
contributes:
|
||||
formats:
|
||||
html:
|
||||
mainfont: Source Sans Pro
|
||||
lang: pt-BR
|
||||
citation: true
|
||||
google-scholar: true
|
||||
smooth-scroll: true
|
||||
theme:
|
||||
light: [cosmo, custom.scss]
|
||||
dark: [superhero, custom.scss]
|
||||
|
||||
Executable
+305
@@ -0,0 +1,305 @@
|
||||
/*-- scss:defaults --*/
|
||||
|
||||
/* TODO: Customize html appearance by setting SCSS variables */
|
||||
/* See https://quarto.org/docs/output-formats/html-themes.html#theme-options */
|
||||
|
||||
/*-- scss:rules --*/
|
||||
|
||||
/* TODO: Provide custom CSS rules */
|
||||
|
||||
/*-- scss:defaults --*/
|
||||
$h2-font-size: 1.6rem !default;
|
||||
$headings-font-weight: 500 !default;
|
||||
$font-size-base: 1.1rem !default;
|
||||
|
||||
/*-- scss:rules --*/
|
||||
main p, main li {
|
||||
text-align: left;
|
||||
hyphens: auto;
|
||||
-webkit-hyphens: auto;
|
||||
font-kerning: auto;
|
||||
}
|
||||
|
||||
.duas_colunas {
|
||||
column-count: 2;
|
||||
column-gap: 20px;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.esquerda p {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.direita p {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.centralizado p {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.justificado p {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.versos {
|
||||
margin: 20px 20px 20px 60px;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.versos p {
|
||||
text-indent: -20px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/*-- As fontes --*/
|
||||
|
||||
@font-face {
|
||||
font-family: 'Source Sans Pro';
|
||||
src: url('/fontes/Source_Sans_3/SourceSans3-VariableFont_wght.ttf');
|
||||
/* Adicione outras variantes da fonte (light, regular, etc.) conforme necessário */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Source Serif';
|
||||
src: url('/fontes/Source_Serif_4/SourceSerif4-VariableFont_opsz,wght.ttf');
|
||||
/* Adicione outras variantes da fonte (light, regular, etc.) conforme necessário */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Source Code Pro';
|
||||
src: url('/fontes/Source_Code_Pro/SourceCodePro-VariableFont_wght.ttf');
|
||||
/* Adicione outras variantes da fonte (light, regular, etc.) conforme necessário */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'EB Garamond';
|
||||
src: url('/fontes/EB_Garamond/EBGaramond-VariableFont_wght.ttf');
|
||||
/* Adicione outras variantes da fonte (light, regular, etc.) conforme necessário */
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Open Sans';
|
||||
src: url('/fontes/Open_Sans/OpenSans-VariableFont_wdth,wght.ttf');
|
||||
/* Adicione outras variantes da fonte (light, regular, etc.) conforme necessário */
|
||||
}
|
||||
|
||||
.sourcesans {
|
||||
font-family: 'Source Sans Pro', sans-serif;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.sourceserif {
|
||||
font-family: 'Source Serif', serif;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.sourcecode {
|
||||
font-family: 'Source Code Pro', monospace;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.ebgaramond {
|
||||
font-family: 'EB Garamond', serif;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.opensans {
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
|
||||
/*-- FIM das fontes --*/
|
||||
|
||||
.fonte_8 {
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
.fonte_9 {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
.fonte_10 {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.fonte_11 {
|
||||
font-size: 1.0rem;
|
||||
}
|
||||
.fonte_12 {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
.fonte_13 {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.fonte_14 {
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
.fonte_15 {
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
.fonte_16 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.espacamento_simples {
|
||||
line-height: 1.2 ;
|
||||
}
|
||||
|
||||
.espacamento_padrao {
|
||||
line-height: 1.5 ;
|
||||
}
|
||||
|
||||
.destaque
|
||||
{
|
||||
display: block;
|
||||
margin: 15px auto;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.continuacao {
|
||||
text-indent: 0;
|
||||
}
|
||||
|
||||
.qrcode {
|
||||
display: block;
|
||||
margin: 20px auto;
|
||||
width: 35%;
|
||||
}
|
||||
|
||||
#como-citar-bibtex, #como-citar-atribuicao {
|
||||
|
||||
border: 1px solid #dedede;
|
||||
border-radius: 2px;
|
||||
padding: 10px;
|
||||
margin-bottom: 1rem;
|
||||
|
||||
}
|
||||
|
||||
#como-citar-atribuicao p {
|
||||
text-indent: -20px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
#como-citar p {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.verso {
|
||||
text-indent: -15px;
|
||||
}
|
||||
|
||||
main li {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
h1{
|
||||
margin-bottom: 18px !important;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h2#toc-title {
|
||||
box-shadow:none;
|
||||
}
|
||||
|
||||
h1, h2 {
|
||||
|
||||
margin-top: 50px;
|
||||
|
||||
}
|
||||
|
||||
#TOC .small_h2{
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
|
||||
#TOC a {
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.autores{
|
||||
margin-bottom: 30px;
|
||||
margin-top: -15px;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
div.autores p {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#direitos-autorais p {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
blockquote{
|
||||
text-align: left;
|
||||
hyphens: auto;
|
||||
font-kerning: auto;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
blockquote+p span div {
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
font-size: unset;
|
||||
}
|
||||
.references div{
|
||||
text-indent: -20px;
|
||||
margin-left: 20px;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.citation div {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
|
||||
.figure-caption {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.contador-figura{
|
||||
font-weight: bold;
|
||||
font-variant: small-caps;
|
||||
}
|
||||
|
||||
mjx-container {
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 400px){
|
||||
|
||||
.qrcode {
|
||||
width: 75%;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media (max-width: 500px){
|
||||
|
||||
.duas_colunas {
|
||||
column-count: 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 991.98px){
|
||||
body .page-columns, body.fullcontent:not(.floating):not(.docked) .page-columns, body.slimcontent:not(.floating):not(.docked) .page-columns, body.docked .page-columns, body.docked.slimcontent .page-columns, body.docked.fullcontent .page-columns, body.floating .page-columns, body.floating.slimcontent .page-columns, body.floating.fullcontent .page-columns {
|
||||
display: grid;
|
||||
gap: 0;
|
||||
grid-template-columns: [screen-start] 1.5em [screen-start-inset page-start page-start-inset body-start-outset body-start body-content-start] minmax(0px, 1fr) [body-content-end body-end body-end-outset page-end-inset page-end screen-end-inset] 1.5em [screen-end];
|
||||
}
|
||||
|
||||
#quarto-margin-sidebar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#quarto-content {
|
||||
max-width: 768px;
|
||||
margin: auto;
|
||||
|
||||
}
|
||||
}
|
||||
Executable
+141
@@ -0,0 +1,141 @@
|
||||
function Pandoc(doc)
|
||||
for _, el in pairs(doc.blocks) do
|
||||
if el.t == "Div" then
|
||||
|
||||
local hasFontClass = false
|
||||
local fontFamily = ''
|
||||
local hasAlinhamentoClass = false
|
||||
local alinhamento = ''
|
||||
local hasFontSizeClass = false
|
||||
local fontSize = ''
|
||||
local hasEntreLinhasClass = false
|
||||
local entreLinhas = ''
|
||||
|
||||
|
||||
for _, class in ipairs(el.classes) do
|
||||
if class == "ebgaramond" then
|
||||
hasFontClass = true
|
||||
fontFamily = '\\ebgaramond'
|
||||
break
|
||||
elseif class == "sourcesans" then
|
||||
hasFontClass = true
|
||||
fontFamily = '\\sourcesans'
|
||||
break
|
||||
elseif class == "sourcecode" then
|
||||
hasFontClass = true
|
||||
fontFamily = '\\sourcecode'
|
||||
break
|
||||
elseif class == "sourceserif" then
|
||||
hasFontClass = true
|
||||
fontFamily = '\\sourceserif'
|
||||
break
|
||||
elseif class == "opensans" then
|
||||
hasFontClass = true
|
||||
fontFamily = '\\opensans'
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
for _, class in ipairs(el.classes) do
|
||||
if class == "centralizado" then
|
||||
hasAlinhamentoClass = true
|
||||
alinhamento = '\\centralizado'
|
||||
break
|
||||
elseif class == "esquerda" then
|
||||
hasAlinhamentoClass = true
|
||||
alinhamento = '\\esquerda'
|
||||
break
|
||||
elseif class == "direita" then
|
||||
hasAlinhamentoClass = true
|
||||
alinhamento = '\\direita'
|
||||
break
|
||||
elseif class == "justificado" then
|
||||
hasAlinhamentoClass = true
|
||||
alinhamento = '\\justificado'
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
for _, class in ipairs(el.classes) do
|
||||
if class == "fonte_8" then
|
||||
hasFontSizeClass = true
|
||||
fontSize = '\\fontsize{8pt}{10pt}\\selectfont'
|
||||
break
|
||||
elseif class == "fonte_9" then
|
||||
hasFontSizeClass = true
|
||||
fontSize = '\\fontsize{9pt}{11pt}\\selectfont'
|
||||
break
|
||||
elseif class == "fonte_10" then
|
||||
hasFontSizeClass = true
|
||||
fontSize = '\\fontsize{10pt}{12pt}\\selectfont'
|
||||
break
|
||||
elseif class == "fonte_11" then
|
||||
hasFontSizeClass = true
|
||||
fontSize = '\\fontsize{11pt}{13pt}\\selectfont'
|
||||
break
|
||||
elseif class == "fonte_12" then
|
||||
hasFontSizeClass = true
|
||||
fontSize = '\\fontsize{12pt}{14pt}\\selectfont'
|
||||
break
|
||||
elseif class == "fonte_13" then
|
||||
hasFontSizeClass = true
|
||||
fontSize = '\\fontsize{13pt}{15pt}\\selectfont'
|
||||
break
|
||||
elseif class == "fonte_14" then
|
||||
hasFontSizeClass = true
|
||||
fontSize = '\\fontsize{14pt}{16pt}\\selectfont'
|
||||
break
|
||||
elseif class == "fonte_15" then
|
||||
hasFontSizeClass = true
|
||||
fontSize = '\\fontsize{15pt}{17pt}\\selectfont'
|
||||
break
|
||||
elseif class == "fonte_16" then
|
||||
hasFontSizeClass = true
|
||||
fontSize = '\\fontsize{16pt}{18pt}\\selectfont'
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
for _, class in ipairs(el.classes) do
|
||||
if class == "espacamento_simples" then
|
||||
hasEntreLinhasClass = true
|
||||
entreLinhas = '\\setstretch{1.2}'
|
||||
break
|
||||
elseif class == "espacamento_duplo" then
|
||||
hasEntreLinhasClass = true
|
||||
entreLinhas = '\\setstretch{1.5}'
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if hasFontClass then
|
||||
-- Adiciona o conteúdo antes e depois do elemento
|
||||
table.insert(el.content, 1, pandoc.RawInline("latex", fontFamily))
|
||||
table.insert(el.content, pandoc.RawInline("latex", "\\sourcesans"))
|
||||
|
||||
end
|
||||
|
||||
if hasAlinhamentoClass then
|
||||
-- Adiciona o conteúdo antes e depois do elemento
|
||||
table.insert(el.content, 1, pandoc.RawInline("latex", alinhamento))
|
||||
table.insert(el.content, pandoc.RawInline("latex", "\\justificado"))
|
||||
end
|
||||
|
||||
if hasFontSizeClass then
|
||||
-- Adiciona o conteúdo antes e depois do elemento
|
||||
table.insert(el.content, 1, pandoc.RawInline("latex", fontSize))
|
||||
table.insert(el.content, pandoc.RawInline("latex", "\\normalsize"))
|
||||
end
|
||||
|
||||
if hasEntreLinhasClass then
|
||||
-- Adiciona o conteúdo antes e depois do elemento
|
||||
table.insert(el.content, 1, pandoc.RawInline("latex", entreLinhas))
|
||||
table.insert(el.content, pandoc.RawInline("latex", "\\setstretch{1.5}"))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
return doc
|
||||
end
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
name: Luacheck
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
|
||||
luacheck:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Luacheck
|
||||
uses: lunarmodules/luacheck@v1
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
name: Test
|
||||
|
||||
on: [ push, pull_request ]
|
||||
|
||||
jobs:
|
||||
|
||||
test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
luaVersion: ['luajit', '5.1', '5.2', '5.3', '5.4.4']
|
||||
runs-on: ubuntu-22.04
|
||||
name: test lua ${{ matrix.luaVersion }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup ‘lua’
|
||||
uses: leafo/gh-actions-lua@v9
|
||||
with:
|
||||
luaVersion: ${{ matrix.luaVersion }}
|
||||
buildCache: true
|
||||
- name: Test
|
||||
run: |
|
||||
lua qrtest.lua
|
||||
+1
@@ -0,0 +1 @@
|
||||
docs
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
[submodule "ghpages"]
|
||||
path = ghpages
|
||||
url = [email protected]:speedata/luaqrcode.git
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
std = "max"
|
||||
include_files = {
|
||||
"**/*.lua",
|
||||
"*.rockspec",
|
||||
".luacheckrc"
|
||||
}
|
||||
exclude_files = {
|
||||
".luarocks",
|
||||
"locco/*"
|
||||
}
|
||||
globals = {
|
||||
"testing",
|
||||
"debugging"
|
||||
}
|
||||
max_line_length = false
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
Copyright (c) 2012-2020, Patrick Gundlach (SPEEDATA GMBH) and contributors, see https://github.com/speedata/luaqrcode. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SPEEDATA nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL SPEEDATA BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
doc:
|
||||
lua locco/locco.lua qrencode.lua
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
See the homepage at http://speedata.github.io/luaqrcode/ for more information.
|
||||
|
||||
Special thanks to all contributors. Everything helps: bug reports, patches etc.
|
||||
|
||||
License: 3-clause BSD license<br>
|
||||
Usability status: mature, used in production<br>
|
||||
Maintenance status: maintained (bug fixes)<br>
|
||||
|
||||
Part of the [speedata Publisher](https://www.speedata.de/).
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
(Note from Patrick Gundlach: this is a slightly modified version of locco,
|
||||
I like to use three dashes for locco documentation, two dashes for normal
|
||||
Lua comments.)
|
||||
|
||||
______
|
||||
___ / ________________________
|
||||
__ / _ __ \ ___/ ___/ __ \
|
||||
_ /___/ /_/ / /__ / /__ / /_/ /
|
||||
/_____/\____/\___/ \___/ \____/
|
||||
|
||||
|
||||
Locco is a Lua port of Docco: the original quick-and-dirty, hundred-line-
|
||||
long, literate-programming-style documentation generator. For more information,
|
||||
see the generated docs:
|
||||
|
||||
<http://rgieseke.github.com/locco/>
|
||||
|
||||
Other languages:
|
||||
|
||||
CoffeeScript - <http://jashkenas.github.com/docco/>
|
||||
|
||||
Python - <http://fitzgen.github.com/pycco/>
|
||||
|
||||
Ruby - <http://rtomayko.github.com/rocco/>
|
||||
|
||||
Sh - <http://rtomayko.github.com/shocco/>
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
/*--------------------- Layout and Typography ----------------------------*/
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
||||
font-size: 15px;
|
||||
line-height: 22px;
|
||||
color: #252519;
|
||||
margin: 0; padding: 0;
|
||||
}
|
||||
a {
|
||||
color: #261a3b;
|
||||
}
|
||||
a:visited {
|
||||
color: #261a3b;
|
||||
}
|
||||
p {
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin: 0px 0 15px 0;
|
||||
line-height: 110%;
|
||||
}
|
||||
h1 {
|
||||
margin-top: 40px;
|
||||
}
|
||||
#container {
|
||||
position: relative;
|
||||
}
|
||||
#background {
|
||||
position: fixed;
|
||||
top: 0; left: 525px; right: 0; bottom: 0;
|
||||
background: #f5f5ff;
|
||||
border-left: 1px solid #e5e5ee;
|
||||
z-index: -1;
|
||||
}
|
||||
#jump_to, #jump_page {
|
||||
background: white;
|
||||
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
|
||||
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
|
||||
font: 10px Arial;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
text-align: right;
|
||||
}
|
||||
#jump_to, #jump_wrapper {
|
||||
position: fixed;
|
||||
right: 0; top: 0;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
#jump_wrapper {
|
||||
padding: 0;
|
||||
display: none;
|
||||
}
|
||||
#jump_to:hover #jump_wrapper {
|
||||
display: block;
|
||||
}
|
||||
#jump_page {
|
||||
padding: 5px 0 3px;
|
||||
margin: 0 0 25px 25px;
|
||||
}
|
||||
#jump_page .source {
|
||||
display: block;
|
||||
padding: 5px 10px;
|
||||
text-decoration: none;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
#jump_page .source:hover {
|
||||
background: #f5f5ff;
|
||||
}
|
||||
#jump_page .source:first-child {
|
||||
}
|
||||
table td {
|
||||
border: 0;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
td.docs > table {
|
||||
padding-left: 3px;
|
||||
padding-right: 3px;
|
||||
}
|
||||
|
||||
table.body {
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
td.docs, th.docs {
|
||||
max-width: 450px;
|
||||
min-width: 450px;
|
||||
min-height: 5px;
|
||||
padding: 10px 25px 1px 50px;
|
||||
overflow-x: hidden;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
}
|
||||
.docs pre {
|
||||
margin: 15px 0 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
.docs p tt, .docs p code {
|
||||
background: #f8f8ff;
|
||||
border: 1px solid #dedede;
|
||||
font-size: 12px;
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
.pilwrap {
|
||||
position: relative;
|
||||
}
|
||||
.pilcrow {
|
||||
font: 12px Arial;
|
||||
text-decoration: none;
|
||||
color: #454545;
|
||||
position: absolute;
|
||||
top: 3px; left: -20px;
|
||||
padding: 1px 2px;
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
}
|
||||
td.docs:hover .pilcrow {
|
||||
opacity: 1;
|
||||
}
|
||||
td.code, th.code {
|
||||
padding: 14px 15px 16px 25px;
|
||||
width: 100%;
|
||||
vertical-align: top;
|
||||
background: #f5f5ff;
|
||||
border-left: 1px solid #e5e5ee;
|
||||
}
|
||||
pre, tt, code {
|
||||
font-size: 12px; line-height: 18px;
|
||||
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
|
||||
margin: 0; padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------- Syntax Highlighting -----------------------------*/
|
||||
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
|
||||
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
|
||||
body .hll { background-color: #ffffcc }
|
||||
body .c { color: #408080; font-style: italic } /* Comment */
|
||||
body .err { border: 1px solid #FF0000 } /* Error */
|
||||
body .k { color: #954121 } /* Keyword */
|
||||
body .o { color: #666666 } /* Operator */
|
||||
body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
||||
body .cp { color: #BC7A00 } /* Comment.Preproc */
|
||||
body .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
||||
body .cs { color: #408080; font-style: italic } /* Comment.Special */
|
||||
body .gd { color: #A00000 } /* Generic.Deleted */
|
||||
body .ge { font-style: italic } /* Generic.Emph */
|
||||
body .gr { color: #FF0000 } /* Generic.Error */
|
||||
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||||
body .gi { color: #00A000 } /* Generic.Inserted */
|
||||
body .go { color: #808080 } /* Generic.Output */
|
||||
body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
||||
body .gs { font-weight: bold } /* Generic.Strong */
|
||||
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
||||
body .gt { color: #0040D0 } /* Generic.Traceback */
|
||||
body .kc { color: #954121 } /* Keyword.Constant */
|
||||
body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
|
||||
body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
|
||||
body .kp { color: #954121 } /* Keyword.Pseudo */
|
||||
body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
|
||||
body .kt { color: #B00040 } /* Keyword.Type */
|
||||
body .m { color: #666666 } /* Literal.Number */
|
||||
body .s { color: #219161 } /* Literal.String */
|
||||
body .na { color: #7D9029 } /* Name.Attribute */
|
||||
body .nb { color: #954121 } /* Name.Builtin */
|
||||
body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
||||
body .no { color: #880000 } /* Name.Constant */
|
||||
body .nd { color: #AA22FF } /* Name.Decorator */
|
||||
body .ni { color: #999999; font-weight: bold } /* Name.Entity */
|
||||
body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
||||
body .nf { color: #0000FF } /* Name.Function */
|
||||
body .nl { color: #A0A000 } /* Name.Label */
|
||||
body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
||||
body .nt { color: #954121; font-weight: bold } /* Name.Tag */
|
||||
body .nv { color: #19469D } /* Name.Variable */
|
||||
body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
||||
body .w { color: #bbbbbb } /* Text.Whitespace */
|
||||
body .mf { color: #666666 } /* Literal.Number.Float */
|
||||
body .mh { color: #666666 } /* Literal.Number.Hex */
|
||||
body .mi { color: #666666 } /* Literal.Number.Integer */
|
||||
body .mo { color: #666666 } /* Literal.Number.Oct */
|
||||
body .sb { color: #219161 } /* Literal.String.Backtick */
|
||||
body .sc { color: #219161 } /* Literal.String.Char */
|
||||
body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
|
||||
body .s2 { color: #219161 } /* Literal.String.Double */
|
||||
body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
||||
body .sh { color: #219161 } /* Literal.String.Heredoc */
|
||||
body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
||||
body .sx { color: #954121 } /* Literal.String.Other */
|
||||
body .sr { color: #BB6688 } /* Literal.String.Regex */
|
||||
body .s1 { color: #219161 } /* Literal.String.Single */
|
||||
body .ss { color: #19469D } /* Literal.String.Symbol */
|
||||
body .bp { color: #954121 } /* Name.Builtin.Pseudo */
|
||||
body .vc { color: #19469D } /* Name.Variable.Class */
|
||||
body .vg { color: #19469D } /* Name.Variable.Global */
|
||||
body .vi { color: #19469D } /* Name.Variable.Instance */
|
||||
body .il { color: #666666 } /* Literal.Number.Integer.Long */
|
||||
+266
@@ -0,0 +1,266 @@
|
||||
#!/usr/bin/env lua
|
||||
-- __Locco__ is a Lua port of [Docco](http://jashkenas.github.com/docco/),
|
||||
-- the quick-and-dirty, hundred-line-long, literate-programming-style
|
||||
-- documentation generator. It produces HTML that displays your comments
|
||||
-- alongside your code. Comments are passed through
|
||||
-- [Markdown](http://daringfireball.net/projects/markdown/), and code is
|
||||
-- syntax highlighted.
|
||||
-- This page is the result of running Locco against its own source file:
|
||||
-- locco.lua locco.lua
|
||||
--
|
||||
-- For its syntax highlighting Locco relies on the help of
|
||||
-- [David Manura](http://lua-users.org/wiki/DavidManura)'s
|
||||
-- [Lua Balanced](https://github.com/davidm/lua-balanced) to split
|
||||
-- up the code. As a markdown engine it ships with
|
||||
-- [Niklas Frykholm](http://www.frykholm.se/)'s
|
||||
-- [markdown.lua](http://www.frykholm.se/files/markdown.lua) in the [Lua 5.2
|
||||
-- compatible version](https://github.com/speedata/luamarkdown) from
|
||||
-- [Patrick Gundlach](https://github.com/pgundlach). Otherwise there
|
||||
-- are no external dependencies.
|
||||
--
|
||||
-- The generated HTML documentation for the given source files is saved
|
||||
-- into a `docs` directory. If you have Locco on your path you can run it from
|
||||
-- the command-line:
|
||||
-- locco.lua project/*.lua
|
||||
--
|
||||
-- Locco is monolingual, but there are many projects written in
|
||||
-- and with support for other languages, see the
|
||||
-- [Docco](http://jashkenas.github.com/docco/) page for a list.<br>
|
||||
-- The [source for Locco](https://github.com/rgieseke/locco) is available on
|
||||
-- GitHub, and released under the MIT
|
||||
-- license.
|
||||
|
||||
-- ### Setup & Helpers
|
||||
|
||||
-- Add script path to package path to find submodules.
|
||||
local script_path = arg[0]:match('(.+)/.+')
|
||||
package.path = table.concat({
|
||||
script_path..'/?.lua',
|
||||
package.path
|
||||
}, ';')
|
||||
|
||||
-- Load markdown.lua.
|
||||
local md = require 'markdown'
|
||||
-- Load Lua Balanced.
|
||||
local lb = require 'luabalanced'
|
||||
-- Load HTML templates.
|
||||
local template = require 'template'
|
||||
|
||||
-- Ensure the `docs` directory exists and return the _path_ of the source file.<br>
|
||||
-- Parameter:<br>
|
||||
-- _source_: The source file for which documentation is generated.<br>
|
||||
local function ensure_directory(source)
|
||||
local path = source:match('(.+)/.+$')
|
||||
if not path then path = '.' end
|
||||
os.execute('mkdir -p '..path..'/ghpages/docs')
|
||||
return path
|
||||
end
|
||||
|
||||
-- Insert HTML entities in a string.<br>
|
||||
-- Parameter:<br>
|
||||
-- _s_: String to escape.<br>
|
||||
local function escape(s)
|
||||
s = s:gsub('&', '&')
|
||||
s = s:gsub('<', '<')
|
||||
s = s:gsub('>', '>')
|
||||
s = s:gsub('%%', '%')
|
||||
return s
|
||||
end
|
||||
|
||||
--local function replace_percent(s)
|
||||
-- s = s:gsub('%%', '%%%%')
|
||||
-- return s
|
||||
--end
|
||||
|
||||
-- Define the Lua keywords, built-in functions and operators that should
|
||||
-- be highlighted.
|
||||
local keywords = { 'break', 'do', 'else', 'elseif', 'end', 'false', 'for',
|
||||
'function', 'if', 'in', 'local', 'nil', 'repeat', 'return',
|
||||
'then', 'true', 'until', 'while' }
|
||||
local functions = { 'assert', 'collectgarbage', 'dofile', 'error', 'getfenv',
|
||||
'getmetatable', 'ipairs', 'load', 'loadfile', 'loadstring',
|
||||
'module', 'next', 'pairs', 'pcall', 'print', 'rawequal',
|
||||
'rawget', 'rawset', 'require', 'setfenv', 'setmetatable',
|
||||
'tonumber', 'tostring', 'type', 'unpack', 'xpcall' }
|
||||
local operators = { 'and', 'not', 'or' }
|
||||
|
||||
-- Wrap an item from a list of Lua keywords in a span template or return the
|
||||
-- unchanged item.<br>
|
||||
-- Parameters:<br>
|
||||
-- _item_: An item of a code snippet.<br>
|
||||
-- _item\_list_: List of keywords or functions.<br>
|
||||
-- _span\_class_: Style sheet class.<br>
|
||||
local function wrap_in_span(item, item_list, span_class)
|
||||
for i=1, #item_list do
|
||||
if item_list[i] == item then
|
||||
item = '<span class="'..span_class..'">'..item..'</span>'
|
||||
break
|
||||
end
|
||||
end
|
||||
return item
|
||||
end
|
||||
|
||||
-- Quick and dirty source code highlighting. A chunk of code is split into
|
||||
-- comments (at the end of a line), strings and code using the
|
||||
-- [Lua Balanced](https://github.com/davidm/lua-balanced/blob/master/luabalanced.lua)
|
||||
-- module. The code is then split again and matched against lists
|
||||
-- of Lua keywords, functions or operators. All Lua items are wrapped into
|
||||
-- a span having one of the classes defined in the Locco style sheet.<br>
|
||||
-- Parameter:<br>
|
||||
-- _code_: Chunk of code to highlight.<br>
|
||||
local function highlight_lua(code)
|
||||
local out = lb.gsub(code,
|
||||
function(u, s)
|
||||
local sout
|
||||
if u == 'c' then -- Comments.
|
||||
sout = '<span class="c">'..escape(s)..'</span>'
|
||||
elseif u == 's' then -- Strings.
|
||||
sout = '<span class="s">'..escape(s)..'</span>'
|
||||
elseif u == 'e' then -- Code.
|
||||
s = escape(s)
|
||||
-- First highlight function names.
|
||||
s = s:gsub('function ([%w_:%.]+)', 'function <span class="nf">%1</span>')
|
||||
-- There might be a non-keyword at the beginning of the snippet.
|
||||
sout = s:match('^(%A+)') or ''
|
||||
-- Iterate through Lua items and try to wrap operators,
|
||||
-- keywords and built-in functions in span elements.
|
||||
-- If nothing was highlighted go to the next category.
|
||||
for item, sep in s:gmatch('([%a_]+)(%A+)') do
|
||||
local span, n = wrap_in_span(item, operators, 'o')
|
||||
if span == item then
|
||||
span, n = wrap_in_span(item, keywords, 'k')
|
||||
end
|
||||
if span == item then
|
||||
span, n = wrap_in_span(item, functions, 'nt')
|
||||
end
|
||||
sout = sout..span..sep
|
||||
end
|
||||
end
|
||||
return sout
|
||||
end)
|
||||
out = '<div class="highlight"><pre>'..out..'</pre></div>'
|
||||
return out
|
||||
end
|
||||
|
||||
|
||||
-- ### Main Documentation Generation Functions
|
||||
|
||||
-- Given a string of source code, parse out each comment and the code that
|
||||
-- follows it, and create an individual section for it. Sections take the form:
|
||||
--
|
||||
-- {
|
||||
-- docs_text = ...,
|
||||
-- docs_html = ...,
|
||||
-- code_text = ...,
|
||||
-- code_html = ...,
|
||||
-- }
|
||||
--
|
||||
-- Parameter:<br>
|
||||
-- _source_: The source file to process.<br>
|
||||
local function parse(source)
|
||||
local sections = {}
|
||||
local has_code = false
|
||||
local docs_text, code_text = '', ''
|
||||
for line in io.lines(source) do
|
||||
if line:match('^%s*%-%-%-') then
|
||||
if has_code then
|
||||
code_text = code_text:gsub('\n\n$', '\n') -- remove empty trailing line
|
||||
sections[#sections + 1] = { ['docs_text'] = docs_text,
|
||||
['code_text'] = code_text }
|
||||
has_code = false
|
||||
docs_text, code_text = '', ''
|
||||
end
|
||||
docs_text = docs_text..line:gsub('%s*(%-%-%-%s?)', '', 1)..'\n'
|
||||
else
|
||||
if not line:match('^#!') then -- ignore #!/usr/bin/lua
|
||||
has_code = true
|
||||
code_text = code_text..line..'\n'
|
||||
end
|
||||
end
|
||||
end
|
||||
sections[#sections + 1] = { ['docs_text'] = docs_text,
|
||||
['code_text'] = code_text }
|
||||
return sections
|
||||
end
|
||||
|
||||
-- Loop through a table of split sections and convert the documentation
|
||||
-- from Markdown to HTML and pass the code through Locco's syntax
|
||||
-- highlighting. Add _docs\_html_ and _code\_html_ elements to the sections
|
||||
-- table.<br>
|
||||
-- Parameter:<br>
|
||||
-- _sections_: A table with split sections.<br>
|
||||
local function highlight(sections)
|
||||
for i=1, #sections do
|
||||
sections[i]['docs_html'] = md.markdown(sections[i]['docs_text'])
|
||||
sections[i]['code_html'] = highlight_lua(sections[i]['code_text'])
|
||||
end
|
||||
return sections
|
||||
end
|
||||
|
||||
-- After the highlighting is done, the template is filled with the documentation
|
||||
-- and code snippets and an HTML file is written.<br>
|
||||
-- Parameters:<br>
|
||||
-- _source_: The source file.<br>
|
||||
-- _path_: Path of the source file.<br>
|
||||
-- _filename_: The filename of the source file.<br>
|
||||
-- _sections_: A table with the original sections and rendered as HTML.<br>
|
||||
-- _jump\_to_: A HTML chunk with links to other documentation files.
|
||||
local function generate_html(source, path, filename, sections, jump_to)
|
||||
local f, err = io.open(path..'/ghpages/docs/'..filename:gsub('lua$', 'html'), 'wb')
|
||||
if err then print(err) end
|
||||
local h = template.header:gsub('%%title%%', source)
|
||||
h = h:gsub('%%jump%%', jump_to)
|
||||
f:write(h)
|
||||
for i=1, #sections do
|
||||
local t = template.table_entry:gsub('%%index%%', i..'')
|
||||
t = t:gsub('%%docs_html%%', sections[i]['docs_html'])
|
||||
t = t:gsub('%%code_html%%', sections[i]['code_html'])
|
||||
f:write(t)
|
||||
end
|
||||
f:write(template.footer)
|
||||
f:close()
|
||||
end
|
||||
|
||||
-- Generate the documentation for a source file by reading it in,
|
||||
-- splitting it up into comment/code sections, highlighting and merging
|
||||
-- them into an HTML template.<br>
|
||||
-- Parameters:<br>
|
||||
-- _source_: The source file to process.<br>
|
||||
-- _path_: Path of the source file.<br>
|
||||
-- _filename_: The filename of the source file.<br>
|
||||
-- _jump\_to_: A HTML chunk with links to other documentation files.
|
||||
local function generate_documentation(source, path, filename, jump_to)
|
||||
local sections = parse(source)
|
||||
local sections = highlight(sections)
|
||||
generate_html(source, path, filename, sections, jump_to)
|
||||
end
|
||||
|
||||
|
||||
-- Run the script.
|
||||
|
||||
-- Generate HTML links to other files in the documentation.
|
||||
local jump_to = ''
|
||||
if #arg > 1 then
|
||||
jump_to = template.jump_start
|
||||
for i=1, #arg do
|
||||
local link = arg[i]:gsub('lua$', 'html')
|
||||
link = link:match('.+/(.+)$') or link
|
||||
local t = template.jump:gsub('%%jump_html%%', link)
|
||||
t = t:gsub('%%jump_lua%%', arg[i])
|
||||
jump_to = jump_to..t
|
||||
end
|
||||
jump_to = jump_to..template.jump_end
|
||||
end
|
||||
|
||||
-- Make sure the output directory exists, generate the HTML files for each
|
||||
-- source file, print what's happening and write the style sheet.
|
||||
local path = ensure_directory(arg[1])
|
||||
for i=1, #arg do
|
||||
local filename = arg[i]:match('.+/(.+)$') or arg[i]
|
||||
generate_documentation(arg[i], path, filename, jump_to)
|
||||
print(arg[i]..' --> '..path..'/ghpages/docs/'..filename:gsub('lua$', 'html'))
|
||||
end
|
||||
local f, err = io.open(path..'/'..'ghpages/docs/locco.css', 'wb')
|
||||
if err then print(err) end
|
||||
f:write(template.css)
|
||||
f:close()
|
||||
@@ -0,0 +1,367 @@
|
||||
--[==[
|
||||
|
||||
LUA MODULE
|
||||
|
||||
luabalanced v$(_VERSION) - Functions for matching delimited snippets of Lua code in a string
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
local LB = require "luabalanced"
|
||||
-- Extract Lua expression starting at position 4.
|
||||
print(LB.match_expression("if x^2 + x > 5 then print(x) end", 4))
|
||||
--> x^2 + x > 5 16
|
||||
-- Extract Lua string starting at (default) position 1.
|
||||
print(LB.match_string([["test\"123" .. "more"]]))
|
||||
--> "test\"123" 12
|
||||
-- Break Lua code into code types.
|
||||
LB.gsub([[
|
||||
local x = 1 -- test
|
||||
print("x=", x)
|
||||
]], function(u, s)
|
||||
print(u .. '[' .. s .. ']')
|
||||
end)
|
||||
--[[output:
|
||||
e[ local x = 1 ]
|
||||
c[-- test
|
||||
]
|
||||
e[ print(]
|
||||
s["x="]
|
||||
e[, x)
|
||||
]
|
||||
]]
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This module can, for example, match a Lua string, Lua comment, or Lua
|
||||
expression. It is useful in particular for source filters or parsing
|
||||
Lua snippets embedded in another language. It is inspired by Damian Conway's
|
||||
Text::Balanced [1] in Perl. The unique feature of this implementation
|
||||
is that that it does not rigorously lex and parse the Lua grammar.
|
||||
It doesn't need to. It assumes during the parse that the Lua code is
|
||||
syntactically correct (which can be verified later using loadstring).
|
||||
By assuming this, extraction of delimited sequences is significantly
|
||||
simplified yet can still be robust, and it also supports supersets
|
||||
of the Lua grammar. The code, which is written entirely in Lua,
|
||||
is just under 200 lines of Lua code (compare to Yueliang used in
|
||||
MetaLua, where the lexer alone is a few hundred lines).
|
||||
|
||||
API
|
||||
|
||||
LB.match_string(s, pos) --> string, posnew
|
||||
|
||||
Match Lua string in string <s> starting at position `pos`.
|
||||
Returns `string`, `posnew`, where `string` is the matched
|
||||
string (or nil on no match) and `posnew` is the character
|
||||
following the match (or `pos` on no match).
|
||||
Supports all Lua string syntax: "...", '...', [[...]], [=[...]=], etc.
|
||||
|
||||
LB.match_bracketed(s, pos) --> string, posnew
|
||||
|
||||
Match bracketed Lua expression, e.g. "(...)", "{...}", "[...]", "[[...]]",
|
||||
[=[...]=], etc.
|
||||
Function interface is similar to `match_string`.
|
||||
|
||||
LB.match_comment(s, pos) --> string, posnew
|
||||
|
||||
Match Lua comment, e.g. "--...\n", "--[[...]]", "--[=[...]=]", etc.
|
||||
Function interface is similar to `match_string`.
|
||||
|
||||
LB.match_expression(s, pos) --> string, posnew
|
||||
|
||||
Match Lua expression, e.g. "a + b * c[e]".
|
||||
Function interface is similar to match_string.
|
||||
|
||||
LB.match_namelist(s, pos) --> array, posnew
|
||||
|
||||
Match name list (zero or more names). E.g. "a,b,c"
|
||||
Function interface is similar to match_string,
|
||||
but returns array as match.
|
||||
|
||||
M.match_explist(s, pos) --> array, posnew
|
||||
|
||||
Match expression list (zero or more expressions). E.g. "a+b,b*c".
|
||||
Function interface is similar to match_string,
|
||||
but returns array as match.
|
||||
|
||||
M.gsub(s, f)
|
||||
|
||||
Replace snippets of code in Lua code string `s`
|
||||
using replacement function `f(u,sin) --> sout`.
|
||||
`u` is the type of snippet ('c' = comment, 's' = string,
|
||||
'e' = any other code).
|
||||
Snippet is replaced with `sout` (unless `sout` is `nil` or `false`, in
|
||||
which case the original snippet is kept)
|
||||
This is somewhat analogous to `string.gsub`.
|
||||
|
||||
DEPENDENCIES
|
||||
|
||||
None (other than Lua 5.1 or 5.2).
|
||||
|
||||
HOME PAGE
|
||||
|
||||
http://lua-users.org/wiki/LuaBalanced
|
||||
https://github.com/davidm/lua-balanced
|
||||
|
||||
DOWNLOAD/INSTALL
|
||||
|
||||
If using LuaRocks:
|
||||
luarocks install lua-balanced
|
||||
|
||||
Otherwise, download <https://github.com/davidm/lua-balanced/zipball/master>
|
||||
and unzip. Alternately, if using git:
|
||||
git clone git://github.com/davidm/lua-balanced.git
|
||||
cd lua-balanced
|
||||
Optionally unpack:
|
||||
./util.mk
|
||||
or unpack and install in LuaRocks:
|
||||
./util.mk install
|
||||
|
||||
REFERENCES
|
||||
|
||||
[1] http://lua-users.org/wiki/LuaBalanced
|
||||
[2] http://search.cpan.org/dist/Text-Balanced/lib/Text/Balanced.pm
|
||||
|
||||
LICENSE
|
||||
|
||||
(c) 2008-2011 David Manura. Licensed under the same terms as Lua (MIT).
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
(end license)
|
||||
|
||||
--]==]---------------------------------------------------------------------
|
||||
|
||||
local M = {_TYPE='module', _NAME='luabalanaced', _VERSION='0.1.1.20120323'}
|
||||
|
||||
local assert = assert
|
||||
|
||||
-- map opening brace <-> closing brace.
|
||||
local ends = { ['('] = ')', ['{'] = '}', ['['] = ']' }
|
||||
local begins = {}; for k,v in pairs(ends) do begins[v] = k end
|
||||
|
||||
|
||||
local function match_string(s, pos)
|
||||
pos = pos or 1
|
||||
local posa = pos
|
||||
local c = s:sub(pos,pos)
|
||||
if c == '"' or c == "'" then
|
||||
pos = pos + 1
|
||||
while 1 do
|
||||
pos = assert(s:find("[" .. c .. "\\]", pos), 'syntax error')
|
||||
if s:sub(pos,pos) == c then
|
||||
local part = s:sub(posa, pos)
|
||||
return part, pos + 1
|
||||
else
|
||||
pos = pos + 2
|
||||
end
|
||||
end
|
||||
else
|
||||
local sc = s:match("^%[(=*)%[", pos)
|
||||
if sc then
|
||||
local _; _, pos = s:find("%]" .. sc .. "%]", pos)
|
||||
assert(pos)
|
||||
local part = s:sub(posa, pos)
|
||||
return part, pos + 1
|
||||
else
|
||||
return nil, pos
|
||||
end
|
||||
end
|
||||
end
|
||||
M.match_string = match_string
|
||||
|
||||
|
||||
local function match_bracketed(s, pos)
|
||||
pos = pos or 1
|
||||
local posa = pos
|
||||
local ca = s:sub(pos,pos)
|
||||
if not ends[ca] then
|
||||
return nil, pos
|
||||
end
|
||||
local stack = {}
|
||||
while 1 do
|
||||
pos = s:find('[%(%{%[%)%}%]\"\']', pos)
|
||||
assert(pos, 'syntax error: unbalanced')
|
||||
local c = s:sub(pos,pos)
|
||||
if c == '"' or c == "'" then
|
||||
local part; part, pos = match_string(s, pos)
|
||||
assert(part)
|
||||
elseif ends[c] then -- open
|
||||
local mid, posb
|
||||
if c == '[' then mid, posb = s:match('^%[(=*)%[()', pos) end
|
||||
if mid then
|
||||
pos = s:match('%]' .. mid .. '%]()', posb)
|
||||
assert(pos, 'syntax error: long string not terminated')
|
||||
if #stack == 0 then
|
||||
local part = s:sub(posa, pos-1)
|
||||
return part, pos
|
||||
end
|
||||
else
|
||||
stack[#stack+1] = c
|
||||
pos = pos + 1
|
||||
end
|
||||
else -- close
|
||||
assert(stack[#stack] == assert(begins[c]), 'syntax error: unbalanced')
|
||||
stack[#stack] = nil
|
||||
if #stack == 0 then
|
||||
local part = s:sub(posa, pos)
|
||||
return part, pos+1
|
||||
end
|
||||
pos = pos + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
M.match_bracketed = match_bracketed
|
||||
|
||||
|
||||
local function match_comment(s, pos)
|
||||
pos = pos or 1
|
||||
if s:sub(pos, pos+1) ~= '--' then
|
||||
return nil, pos
|
||||
end
|
||||
pos = pos + 2
|
||||
local partt, post = match_string(s, pos)
|
||||
if partt then
|
||||
return '--' .. partt, post
|
||||
end
|
||||
local part; part, pos = s:match('^([^\n]*\n?)()', pos)
|
||||
return '--' .. part, pos
|
||||
end
|
||||
|
||||
|
||||
local wordop = {['and']=true, ['or']=true, ['not']=true}
|
||||
local is_compare = {['>']=true, ['<']=true, ['~']=true}
|
||||
local function match_expression(s, pos)
|
||||
pos = pos or 1
|
||||
local posa = pos
|
||||
local lastident
|
||||
local poscs, posce
|
||||
while pos do
|
||||
local c = s:sub(pos,pos)
|
||||
if c == '"' or c == "'" or c == '[' and s:find('^[=%[]', pos+1) then
|
||||
local part; part, pos = match_string(s, pos)
|
||||
assert(part, 'syntax error')
|
||||
elseif c == '-' and s:sub(pos+1,pos+1) == '-' then
|
||||
-- note: handle adjacent comments in loop to properly support
|
||||
-- backtracing (poscs/posce).
|
||||
poscs = pos
|
||||
while s:sub(pos,pos+1) == '--' do
|
||||
local part; part, pos = match_comment(s, pos)
|
||||
assert(part)
|
||||
pos = s:match('^%s*()', pos)
|
||||
posce = pos
|
||||
end
|
||||
elseif c == '(' or c == '{' or c == '[' then
|
||||
local part; part, pos = match_bracketed(s, pos)
|
||||
elseif c == '=' and s:sub(pos+1,pos+1) == '=' then
|
||||
pos = pos + 2 -- skip over two-char op containing '='
|
||||
elseif c == '=' and is_compare[s:sub(pos-1,pos-1)] then
|
||||
pos = pos + 1 -- skip over two-char op containing '='
|
||||
elseif c:match'^[%)%}%];,=]' then
|
||||
local part = s:sub(posa, pos-1)
|
||||
return part, pos
|
||||
elseif c:match'^[%w_]' then
|
||||
local newident,newpos = s:match('^([%w_]+)()', pos)
|
||||
if pos ~= posa and not wordop[newident] then -- non-first ident
|
||||
local pose = ((posce == pos) and poscs or pos) - 1
|
||||
while s:match('^%s', pose) do pose = pose - 1 end
|
||||
local ce = s:sub(pose,pose)
|
||||
if ce:match'[%)%}\'\"%]]' or
|
||||
ce:match'[%w_]' and not wordop[lastident]
|
||||
then
|
||||
local part = s:sub(posa, pos-1)
|
||||
return part, pos
|
||||
end
|
||||
end
|
||||
lastident, pos = newident, newpos
|
||||
else
|
||||
pos = pos + 1
|
||||
end
|
||||
pos = s:find('[%(%{%[%)%}%]\"\';,=%w_%-]', pos)
|
||||
end
|
||||
local part = s:sub(posa, #s)
|
||||
return part, #s+1
|
||||
end
|
||||
M.match_expression = match_expression
|
||||
|
||||
|
||||
local function match_namelist(s, pos)
|
||||
pos = pos or 1
|
||||
local list = {}
|
||||
while 1 do
|
||||
local c = #list == 0 and '^' or '^%s*,%s*'
|
||||
local item, post = s:match(c .. '([%a_][%w_]*)%s*()', pos)
|
||||
if item then pos = post else break end
|
||||
list[#list+1] = item
|
||||
end
|
||||
return list, pos
|
||||
end
|
||||
M.match_namelist = match_namelist
|
||||
|
||||
|
||||
local function match_explist(s, pos)
|
||||
pos = pos or 1
|
||||
local list = {}
|
||||
while 1 do
|
||||
if #list ~= 0 then
|
||||
local post = s:match('^%s*,%s*()', pos)
|
||||
if post then pos = post else break end
|
||||
end
|
||||
local item; item, pos = match_expression(s, pos)
|
||||
assert(item, 'syntax error')
|
||||
list[#list+1] = item
|
||||
end
|
||||
return list, pos
|
||||
end
|
||||
M.match_explist = match_explist
|
||||
|
||||
|
||||
local function gsub(s, f)
|
||||
local pos = 1
|
||||
local posa = 1
|
||||
local ts = {}
|
||||
while 1 do
|
||||
pos = s:find('[%-\'\"%[]', pos)
|
||||
if not pos then break end
|
||||
if s:match('^%-%-', pos) then
|
||||
local exp = s:sub(posa, pos-1)
|
||||
if #exp > 0 then ts[#ts+1] = (f('e', exp) or exp) end
|
||||
local comment; comment, pos = match_comment(s, pos)
|
||||
ts[#ts+1] = (f('c', assert(comment)) or comment)
|
||||
posa = pos
|
||||
else
|
||||
local posb = s:find('^[\'\"%[]', pos)
|
||||
local str
|
||||
if posb then str, pos = match_string(s, posb) end
|
||||
if str then
|
||||
local exp = s:sub(posa, posb-1)
|
||||
if #exp > 0 then ts[#ts+1] = (f('e', exp) or exp) end
|
||||
ts[#ts+1] = (f('s', str) or str)
|
||||
posa = pos
|
||||
else
|
||||
pos = pos + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
local exp = s:sub(posa)
|
||||
if #exp > 0 then ts[#ts+1] = (f('e', exp) or exp) end
|
||||
return table.concat(ts)
|
||||
end
|
||||
M.gsub = gsub
|
||||
|
||||
|
||||
return M
|
||||
+1345
File diff suppressed because it is too large.
Load diff
+255
@@ -0,0 +1,255 @@
|
||||
local M = {}
|
||||
|
||||
M.header = [[<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>%title%</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" media="all" href="locco.css" />
|
||||
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
%jump%
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="docs">
|
||||
<h1>
|
||||
%title%
|
||||
</h1>
|
||||
</th>
|
||||
<th class="code">
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
]]
|
||||
|
||||
M.jump_start = [[
|
||||
<div id="jump_to">
|
||||
Jump To …
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page">
|
||||
]]
|
||||
|
||||
M.jump = [[
|
||||
<a class="source" href="%jump_html%">%jump_lua%</a>
|
||||
]]
|
||||
|
||||
M.jump_end = [[
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
]]
|
||||
|
||||
M.table_entry = [[
|
||||
<tr id="section-%index%">
|
||||
<td class="docs">
|
||||
<div class="pilwrap">
|
||||
<a class="pilcrow" href="#section-%index%">¶</a>
|
||||
</div>
|
||||
%docs_html%
|
||||
</td>
|
||||
<td class="code">
|
||||
%code_html%
|
||||
</td>
|
||||
</tr>]]
|
||||
|
||||
M.footer = [[</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>]]
|
||||
|
||||
M.css = [[/*--------------------- Layout and Typography ----------------------------*/
|
||||
body {
|
||||
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
||||
font-size: 15px;
|
||||
line-height: 22px;
|
||||
color: #252519;
|
||||
margin: 0; padding: 0;
|
||||
}
|
||||
a {
|
||||
color: #261a3b;
|
||||
}
|
||||
a:visited {
|
||||
color: #261a3b;
|
||||
}
|
||||
p {
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin: 0px 0 15px 0;
|
||||
}
|
||||
h1 {
|
||||
margin-top: 40px;
|
||||
}
|
||||
#container {
|
||||
position: relative;
|
||||
}
|
||||
#background {
|
||||
position: fixed;
|
||||
top: 0; left: 525px; right: 0; bottom: 0;
|
||||
background: #f5f5ff;
|
||||
border-left: 1px solid #e5e5ee;
|
||||
z-index: -1;
|
||||
}
|
||||
#jump_to, #jump_page {
|
||||
background: white;
|
||||
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
|
||||
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
|
||||
font: 10px Arial;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
text-align: right;
|
||||
}
|
||||
#jump_to, #jump_wrapper {
|
||||
position: fixed;
|
||||
right: 0; top: 0;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
#jump_wrapper {
|
||||
padding: 0;
|
||||
display: none;
|
||||
}
|
||||
#jump_to:hover #jump_wrapper {
|
||||
display: block;
|
||||
}
|
||||
#jump_page {
|
||||
padding: 5px 0 3px;
|
||||
margin: 0 0 25px 25px;
|
||||
}
|
||||
#jump_page .source {
|
||||
display: block;
|
||||
padding: 5px 10px;
|
||||
text-decoration: none;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
#jump_page .source:hover {
|
||||
background: #f5f5ff;
|
||||
}
|
||||
#jump_page .source:first-child {
|
||||
}
|
||||
table td {
|
||||
border: 0;
|
||||
outline: 0;
|
||||
}
|
||||
td.docs, th.docs {
|
||||
max-width: 450px;
|
||||
min-width: 450px;
|
||||
min-height: 5px;
|
||||
padding: 10px 25px 1px 50px;
|
||||
overflow-x: hidden;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
}
|
||||
.docs pre {
|
||||
margin: 15px 0 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
.docs p tt, .docs p code {
|
||||
background: #f8f8ff;
|
||||
border: 1px solid #dedede;
|
||||
font-size: 12px;
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
.pilwrap {
|
||||
position: relative;
|
||||
}
|
||||
.pilcrow {
|
||||
font: 12px Arial;
|
||||
text-decoration: none;
|
||||
color: #454545;
|
||||
position: absolute;
|
||||
top: 3px; left: -20px;
|
||||
padding: 1px 2px;
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
}
|
||||
td.docs:hover .pilcrow {
|
||||
opacity: 1;
|
||||
}
|
||||
td.code, th.code {
|
||||
padding: 14px 15px 16px 25px;
|
||||
width: 100%;
|
||||
vertical-align: top;
|
||||
background: #f5f5ff;
|
||||
border-left: 1px solid #e5e5ee;
|
||||
}
|
||||
pre, tt, code {
|
||||
font-size: 12px; line-height: 18px;
|
||||
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
|
||||
margin: 0; padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------- Syntax Highlighting -----------------------------*/
|
||||
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
|
||||
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
|
||||
body .hll { background-color: #ffffcc }
|
||||
body .c { color: #408080; font-style: italic } /* Comment */
|
||||
body .err { border: 1px solid #FF0000 } /* Error */
|
||||
body .k { color: #954121 } /* Keyword */
|
||||
body .o { color: #666666 } /* Operator */
|
||||
body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
||||
body .cp { color: #BC7A00 } /* Comment.Preproc */
|
||||
body .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
||||
body .cs { color: #408080; font-style: italic } /* Comment.Special */
|
||||
body .gd { color: #A00000 } /* Generic.Deleted */
|
||||
body .ge { font-style: italic } /* Generic.Emph */
|
||||
body .gr { color: #FF0000 } /* Generic.Error */
|
||||
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||||
body .gi { color: #00A000 } /* Generic.Inserted */
|
||||
body .go { color: #808080 } /* Generic.Output */
|
||||
body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
||||
body .gs { font-weight: bold } /* Generic.Strong */
|
||||
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
||||
body .gt { color: #0040D0 } /* Generic.Traceback */
|
||||
body .kc { color: #954121 } /* Keyword.Constant */
|
||||
body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
|
||||
body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
|
||||
body .kp { color: #954121 } /* Keyword.Pseudo */
|
||||
body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
|
||||
body .kt { color: #B00040 } /* Keyword.Type */
|
||||
body .m { color: #666666 } /* Literal.Number */
|
||||
body .s { color: #219161 } /* Literal.String */
|
||||
body .na { color: #7D9029 } /* Name.Attribute */
|
||||
body .nb { color: #954121 } /* Name.Builtin */
|
||||
body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
||||
body .no { color: #880000 } /* Name.Constant */
|
||||
body .nd { color: #AA22FF } /* Name.Decorator */
|
||||
body .ni { color: #999999; font-weight: bold } /* Name.Entity */
|
||||
body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
||||
body .nf { color: #0000FF } /* Name.Function */
|
||||
body .nl { color: #A0A000 } /* Name.Label */
|
||||
body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
||||
body .nt { color: #954121; font-weight: bold } /* Name.Tag */
|
||||
body .nv { color: #19469D } /* Name.Variable */
|
||||
body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
||||
body .w { color: #bbbbbb } /* Text.Whitespace */
|
||||
body .mf { color: #666666 } /* Literal.Number.Float */
|
||||
body .mh { color: #666666 } /* Literal.Number.Hex */
|
||||
body .mi { color: #666666 } /* Literal.Number.Integer */
|
||||
body .mo { color: #666666 } /* Literal.Number.Oct */
|
||||
body .sb { color: #219161 } /* Literal.String.Backtick */
|
||||
body .sc { color: #219161 } /* Literal.String.Char */
|
||||
body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
|
||||
body .s2 { color: #219161 } /* Literal.String.Double */
|
||||
body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
||||
body .sh { color: #219161 } /* Literal.String.Heredoc */
|
||||
body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
||||
body .sx { color: #954121 } /* Literal.String.Other */
|
||||
body .sr { color: #BB6688 } /* Literal.String.Regex */
|
||||
body .s1 { color: #219161 } /* Literal.String.Single */
|
||||
body .ss { color: #19469D } /* Literal.String.Symbol */
|
||||
body .bp { color: #954121 } /* Name.Builtin.Pseudo */
|
||||
body .vc { color: #19469D } /* Name.Variable.Class */
|
||||
body .vg { color: #19469D } /* Name.Variable.Global */
|
||||
body .vi { color: #19469D } /* Name.Variable.Instance */
|
||||
body .il { color: #666666 } /* Literal.Number.Integer.Long */
|
||||
]]
|
||||
|
||||
return M
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env lua
|
||||
|
||||
local qrencode = dofile("qrencode.lua")
|
||||
|
||||
|
||||
-- padding: number of padding rows/columns around QR code
|
||||
local function matrix_to_string( tab, padding,padding_char,white_pixel,black_pixel )
|
||||
local padding_string
|
||||
local str_tab = {} -- hold each row of the qr code in a cell
|
||||
|
||||
-- Add (padding) blank columns at the left of the matrix
|
||||
-- (left of each row string), inserting an extra (padding)
|
||||
-- rows at the top and bottom
|
||||
padding_string = string.rep(padding_char,padding)
|
||||
for i=1,#tab + 2*padding do
|
||||
str_tab[i] = padding_string
|
||||
end
|
||||
|
||||
for x=1,#tab do
|
||||
for y=1,#tab do
|
||||
if tab[x][y] > 0 then
|
||||
-- using y + padding because we added (padding) blank columns at the left for each string in str_tab array
|
||||
str_tab[y + padding] = str_tab[y + padding] .. black_pixel
|
||||
elseif tab[x][y] < 0 then
|
||||
str_tab[y + padding] = str_tab[y + padding] .. white_pixel
|
||||
else
|
||||
str_tab[y + padding] = str_tab[y + padding] .. " X"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
padding_string = string.rep(padding_char,#tab)
|
||||
for i=1,padding do
|
||||
-- fills in padding rows at top of matrix
|
||||
str_tab[i] = str_tab[i] .. padding_string
|
||||
-- fills in padding rows at bottom of matrix
|
||||
str_tab[#tab + padding + i] = str_tab[#tab + padding + i] .. padding_string
|
||||
end
|
||||
|
||||
-- Add (padding) blank columns to right of matrix (to the end of each row string)
|
||||
padding_string = string.rep(padding_char,padding)
|
||||
for i=1,#tab + 2*padding do
|
||||
str_tab[i] = str_tab[i] .. padding_string
|
||||
end
|
||||
|
||||
return str_tab
|
||||
end
|
||||
|
||||
|
||||
local use_ansi = false
|
||||
local padding = 1
|
||||
local padding_char
|
||||
local black_pixel = "X"
|
||||
local white_pixel = " "
|
||||
local codeword
|
||||
|
||||
while true do
|
||||
if arg[1] == nil then
|
||||
break
|
||||
elseif arg[1] == "-h" or arg[1] == "--help" then
|
||||
codeword = nil
|
||||
break
|
||||
elseif arg[1] == "-a" then
|
||||
use_ansi = true
|
||||
elseif arg[1] == "-p" then
|
||||
padding = arg[2]
|
||||
table.remove(arg,2)
|
||||
elseif arg[1] == "-c" then
|
||||
padding_char = arg[2]
|
||||
table.remove(arg,2)
|
||||
elseif arg[1] == "-b" then
|
||||
black_pixel = arg[2]
|
||||
table.remove(arg,2)
|
||||
elseif arg[1] == "-w" then
|
||||
white_pixel = arg[2]
|
||||
table.remove(arg,2)
|
||||
else
|
||||
codeword = arg[1]
|
||||
end
|
||||
table.remove(arg,1)
|
||||
end
|
||||
|
||||
if use_ansi then
|
||||
black_pixel = "\27[40m \27[0m"
|
||||
white_pixel = "\27[1;47m \27[0m"
|
||||
end
|
||||
|
||||
padding_char = padding_char or white_pixel
|
||||
|
||||
if codeword then
|
||||
local ok, tab_or_message = qrencode.qrcode(codeword)
|
||||
if not ok then
|
||||
print(tab_or_message)
|
||||
else
|
||||
local rows
|
||||
rows = matrix_to_string(tab_or_message,padding,padding_char,white_pixel,black_pixel)
|
||||
for i=1,#rows do -- prints each "row" of the QR code on a line, one at a time
|
||||
print(rows[i])
|
||||
end
|
||||
end
|
||||
else
|
||||
print("Usage:")
|
||||
print(arg[0] .. " [-a] [-p <num>] [-c <char>] [-b <char>] [-w <char>] <contents>")
|
||||
print("-a : use ansi colors (don't do this on a dos box)")
|
||||
print("-p <num> : use padding of width <num> (default: 1)")
|
||||
print("-b <char>: use <char> for black pixel (default: 'X')")
|
||||
print("-w <char>: use <char> for white pixel (default: ' ')")
|
||||
print("-c <char>: use <char> for padding (default: the white pixel)")
|
||||
end
|
||||
+1351
File diff suppressed because it is too large.
Load diff
+123
@@ -0,0 +1,123 @@
|
||||
#!/usr/bin/env lua
|
||||
|
||||
|
||||
local function err( ... )
|
||||
print(string.format(...))
|
||||
end
|
||||
|
||||
local failed = false
|
||||
local function assert_equal( a,b,func )
|
||||
if a ~= b then
|
||||
err("Assertion failed: %s: %q is not equal to %q",func,tostring(a),tostring(b))
|
||||
failed = true
|
||||
end
|
||||
end
|
||||
|
||||
testing=true
|
||||
|
||||
|
||||
local qrcode = dofile("qrencode.lua")
|
||||
local tab
|
||||
local str = "HELLO WORLD"
|
||||
assert_equal(qrcode.get_mode("0101"), 1,"get_encoding_byte 1")
|
||||
assert_equal(qrcode.get_mode(str), 2,"get_encoding_byte 2")
|
||||
assert_equal(qrcode.get_mode("0-9A-Z $%*./:+-"),2,"get_encoding_byte 3")
|
||||
assert_equal(qrcode.get_mode("foär"), 4,"get_encoding_byte 4")
|
||||
assert_equal(qrcode.get_length(str,1,2),"000001011","get_length")
|
||||
assert_equal(qrcode.binary(5,10),"0000000101","binary()")
|
||||
assert_equal(qrcode.binary(779,11),"01100001011","binary()")
|
||||
assert_equal(qrcode.add_pad_data(1,3,"0010101"),"00101010000000001110110000010001111011000001000111101100000100011110110000010001111011000001000111101100","pad_data")
|
||||
|
||||
tab = qrcode.get_generator_polynominal_adjusted(13,25)
|
||||
assert_equal(tab[1],0,"get_generator_polynominal_adjusted 0")
|
||||
assert_equal(tab[24],74,"get_generator_polynominal_adjusted 24")
|
||||
assert_equal(tab[25],0,"get_generator_polynominal_adjusted 25")
|
||||
tab = qrcode.get_generator_polynominal_adjusted(13,24)
|
||||
assert_equal(tab[1],0,"get_generator_polynominal_adjusted 0")
|
||||
assert_equal(tab[23],74,"get_generator_polynominal_adjusted 23")
|
||||
assert_equal(tab[24],0,"get_generator_polynominal_adjusted 24")
|
||||
|
||||
tab = qrcode.convert_bitstring_to_bytes("00100000010110110000101101111000110100010111001011011100010011010100001101000000111011000001000111101100")
|
||||
assert_equal(tab[1],32,"convert_bitstring_to_bytes")
|
||||
assert_equal(qrcode.bit_xor(141,43), 166,"bit_xor")
|
||||
assert_equal(qrcode.bit_xor(179,0), 179,"bit_xor")
|
||||
|
||||
-- local hello_world_msg_with_ec = "0010000001011011000010110111100011010001011100101101110001001101010000110100000011101100000100011110110010101000010010000001011001010010110110010011011010011100000000000010111000001111101101000111101000010000"
|
||||
|
||||
assert_equal(qrcode.get_pixel_with_mask(0,21,21,1),-1,"get_pixel_with_mask 1")
|
||||
assert_equal(qrcode.get_pixel_with_mask(0,1,1,1),-1,"get_pixel_with_mask 2")
|
||||
local a,b,c,d,e = qrcode.get_version_eclevel_mode_bistringlength(str)
|
||||
assert_equal(a,1,"get_version_eclevel_mode_bistringlength 1")
|
||||
assert_equal(b,3,"get_version_eclevel_mode_bistringlength 2")
|
||||
assert_equal(c,"0010","get_version_eclevel_mode_bistringlength 3")
|
||||
assert_equal(d,2,"get_version_eclevel_mode_bistringlength 4")
|
||||
assert_equal(e,"000001011","get_version_eclevel_mode_bistringlength 5")
|
||||
|
||||
assert_equal(qrcode.encode_string_numeric("01234567"),"000000110001010110011000011","encode string numeric")
|
||||
assert_equal(qrcode.encode_string_ascii(str),"0110000101101111000110100010111001011011100010011010100001101","encode string ascii")
|
||||
assert_equal(qrcode.remainder[40],0,"get_remainder")
|
||||
assert_equal(qrcode.remainder[2],7,"get_remainder")
|
||||
|
||||
|
||||
-------------------
|
||||
-- Error correction
|
||||
-------------------
|
||||
local data = {32, 234, 187, 136, 103, 116, 252, 228, 127, 141, 73, 236, 12, 206, 138, 7, 230, 101, 30, 91, 152, 80, 0, 236, 17, 236, 17, 236}
|
||||
local ec_expected = {73, 31, 138, 44, 37, 176, 170, 36, 254, 246, 191, 187, 13, 137, 84, 63}
|
||||
local ec = qrcode.calculate_error_correction(data,16)
|
||||
for i=1,#ec_expected do
|
||||
assert_equal(ec_expected[i],ec[i],string.format("calculate_error_correction %d",i))
|
||||
end
|
||||
data = {32, 234, 187, 136, 103, 116, 252, 228, 127, 141, 73, 236, 12, 206, 138, 7, 230, 101, 30, 91, 152, 80, 0, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236}
|
||||
ec_expected = {66, 146, 126, 122, 79, 146, 2, 105, 180, 35}
|
||||
ec = qrcode.calculate_error_correction(data,10)
|
||||
for i=1,#ec_expected do
|
||||
assert_equal(ec_expected[i],ec[i],string.format("calculate_error_correction %d",i))
|
||||
end
|
||||
data = {32, 83, 7, 120, 209, 114, 215, 60, 224}
|
||||
ec_expected = {123, 120, 222, 125, 116, 92, 144, 245, 58, 73, 104, 30, 108, 0, 30, 166, 152}
|
||||
ec = qrcode.calculate_error_correction(data,17)
|
||||
for i=1,#ec_expected do
|
||||
assert_equal(ec_expected[i],ec[i],string.format("calculate_error_correction %d",i))
|
||||
end
|
||||
data = {32,83,7,120,209,114,215,60,224,236,17}
|
||||
ec_expected = {3, 67, 244, 57, 183, 14, 171, 101, 213, 52, 148, 3, 144, 148, 6, 155, 3, 252, 228, 100, 11, 56}
|
||||
ec = qrcode.calculate_error_correction(data,22)
|
||||
for i=1,#ec_expected do
|
||||
assert_equal(ec_expected[i],ec[i],string.format("calculate_error_correction %d",i))
|
||||
end
|
||||
data = {236,17,236,17,236, 17,236, 17,236, 17,236}
|
||||
ec_expected = {171, 165, 230, 109, 241, 45, 198, 125, 213, 84, 88, 187, 89, 61, 220, 255, 150, 75, 113, 77, 147, 164}
|
||||
ec = qrcode.calculate_error_correction(data,22)
|
||||
for i=1,#ec_expected do
|
||||
assert_equal(ec_expected[i],ec[i],string.format("calculate_error_correction %d",i))
|
||||
end
|
||||
data = {17,236, 17,236, 17,236,17,236, 17,236, 17,236}
|
||||
ec_expected = {23, 115, 68, 245, 125, 66, 203, 235, 85, 88, 174, 178, 229, 181, 118, 148, 44, 175, 213, 243, 27, 215}
|
||||
ec = qrcode.calculate_error_correction(data,22)
|
||||
for i=1,#ec_expected do
|
||||
assert_equal(ec_expected[i],ec[i],string.format("calculate_error_correction %d",i))
|
||||
end
|
||||
data = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
ec_expected = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
ec = qrcode.calculate_error_correction(data,10)
|
||||
for i=1,#ec_expected do
|
||||
assert_equal(ec_expected[i],ec[i],string.format("calculate_error_correction %d",i))
|
||||
end
|
||||
|
||||
-- "HALLO WELT" in alphanumeric, code 5-H
|
||||
data = { 32,83,7,120,209,114,215,60,224,236,17,236,17,236,17,236, 17,236, 17,236, 17,236, 17, 236, 17,236, 17,236, 17,236, 17,236, 17,236, 17, 236, 17,236, 17,236, 17,236, 17,236, 17,236}
|
||||
local message_expected = {32, 236, 17, 17, 83, 17, 236, 236, 7, 236, 17, 17, 120, 17, 236, 236, 209, 236, 17, 17, 114, 17, 236, 236, 215, 236, 17, 17, 60, 17, 236, 236, 224, 236, 17, 17, 236, 17, 236, 236, 17, 236, 17, 17, 236, 236, 3, 171, 23, 23, 67, 165, 115, 115, 244, 230, 68, 68, 57, 109, 245, 245, 183, 241, 125, 125, 14, 45, 66, 66, 171, 198, 203, 203, 101, 125, 235, 235, 213, 213, 85, 85, 52, 84, 88, 88, 148, 88, 174, 174, 3, 187, 178, 178, 144, 89, 229, 229, 148, 61, 181, 181, 6, 220, 118, 118, 155, 255, 148, 148, 3, 150, 44, 44, 252, 75, 175, 175, 228, 113, 213, 213, 100, 77, 243, 243, 11, 147, 27, 27, 56, 164, 215, 215}
|
||||
local tmp = qrcode.arrange_codewords_and_calculate_ec(5,4,data)
|
||||
local message = qrcode.convert_bitstring_to_bytes(tmp)
|
||||
for i=1,#message do
|
||||
assert_equal(message_expected[i],message[i],string.format("arrange_codewords_and_calculate_ec %d",i))
|
||||
end
|
||||
|
||||
print("Tests end here")
|
||||
if failed then
|
||||
print("Some tests failed, see above")
|
||||
else
|
||||
print("Everything looks fine")
|
||||
end
|
||||
os.exit(failed and 1 or 0)
|
||||
+200
@@ -0,0 +1,200 @@
|
||||
import yaml
|
||||
|
||||
# Função para abrir e carregar o arquivo YAML
|
||||
def load_yaml_file(filename):
|
||||
with open(filename, 'r', encoding='utf-8') as file:
|
||||
return yaml.safe_load(file)
|
||||
|
||||
# Função para salvar o arquivo YAML
|
||||
def save_yaml_file(data, filename):
|
||||
with open(filename, 'w', encoding='utf-8') as file:
|
||||
yaml.dump(data, file, default_flow_style=False, allow_unicode=True, sort_keys=False)
|
||||
|
||||
|
||||
# Abrir o arquivo _moan-config.yml e extrair as informações necessárias
|
||||
moan_config = load_yaml_file('_moan-config.yml')
|
||||
|
||||
# Abrir _quarto.yml
|
||||
quarto_data = load_yaml_file('_quarto.yml')
|
||||
|
||||
metadados_total = moan_config.get('metadados', {})
|
||||
|
||||
metadados = metadados_total.get('global', {})
|
||||
|
||||
site_url = ''
|
||||
|
||||
|
||||
# Mover conteúdo de pasta-livro-finalizado para output-dir em _quarto-html.yml e _quarto-pdf.yml, definir o site_url completo e atualizar o campo capa
|
||||
output_dirs = moan_config.get('pasta-livro-finalizado', {})
|
||||
|
||||
for file_suffix in ['-html', '-pdf']:
|
||||
output_dir_key = 'html' if file_suffix == '-html' else 'pdf'
|
||||
output_dir = output_dirs.get(output_dir_key, '')
|
||||
|
||||
# Processar _quarto-html.yml e _quarto-pdf.yml
|
||||
filename = f'_quarto{file_suffix}.yml'
|
||||
data = load_yaml_file(filename)
|
||||
|
||||
# Atualizar output-dir em project
|
||||
if 'project' not in data:
|
||||
data['project'] = {}
|
||||
data['project']['output-dir'] = output_dir
|
||||
|
||||
# Montar site-url completo
|
||||
if output_dir_key == 'html':
|
||||
site_url = moan_config.get('site-de-publicacao', '') + '/' + output_dir
|
||||
endereco_capa = site_url + '/' + metadados.get('capa', '')
|
||||
|
||||
# atualizar campo capa em moan-dados.
|
||||
metadados['capa'] = endereco_capa
|
||||
|
||||
# Configurar moan-dados
|
||||
if 'moan-dados' not in data:
|
||||
data['moan-dados'] = {}
|
||||
|
||||
moan_dados = data.get('moan-dados', {}) # Obtém os metadados existentes ou cria um dicionário vazio
|
||||
|
||||
metadados_especificos_sem_ark = metadados_total.get(output_dir_key, {})
|
||||
|
||||
if 'ark' in moan_dados:
|
||||
|
||||
ark = moan_dados['ark']
|
||||
|
||||
metadados_especificos = {"ark": ark, **metadados_especificos_sem_ark, **metadados}
|
||||
|
||||
data['moan-dados'] = metadados_especificos
|
||||
|
||||
else:
|
||||
data['moan-dados'] = {**metadados_especificos_sem_ark, **metadados}
|
||||
|
||||
|
||||
|
||||
# Salvar as alterações
|
||||
save_yaml_file(data, filename)
|
||||
|
||||
|
||||
|
||||
|
||||
# Processar as alterações em _quarto-html.yml e _quarto-pdf.yml
|
||||
for file_suffix in ['-html', '-pdf']:
|
||||
capitulos_a_excluir_key = 'html' if file_suffix == '-html' else 'pdf'
|
||||
capitulos_a_excluir = moan_config['capitulos-a-excluir'].get(capitulos_a_excluir_key, [])
|
||||
|
||||
# Processar _quarto-html.yml e _quarto-pdf.yml
|
||||
filename = f'_quarto{file_suffix}.yml'
|
||||
data = load_yaml_file(filename)
|
||||
|
||||
# Adicionar metadados a moan-dados
|
||||
moan_dados = data.get('moan-dados', {}) # Obtém os metadados existentes ou cria um dicionário vazio
|
||||
moan_dados = {**moan_dados, **metadados} # Adiciona ou atualiza os novos metadados
|
||||
data['moan-dados'] = moan_dados
|
||||
|
||||
# Processar capitulos
|
||||
capitulos = moan_config.get('capitulos', [])
|
||||
|
||||
capitulos = [capitulo for capitulo in capitulos if capitulo not in capitulos_a_excluir]
|
||||
|
||||
if 'book' not in data:
|
||||
data['book'] = {}
|
||||
if 'chapters' not in data['book']:
|
||||
data['book']['chapters'] = []
|
||||
data['book']['chapters'] = capitulos
|
||||
|
||||
# Salvar as alterações
|
||||
save_yaml_file(data, filename)
|
||||
|
||||
|
||||
|
||||
# Atualizar as chaves em book
|
||||
if 'book' in quarto_data:
|
||||
book = quarto_data['book']
|
||||
|
||||
metadados_html = metadados_total.get('html', {})
|
||||
|
||||
metadados_pdf = metadados_total.get('pdf', {})
|
||||
|
||||
politica_de_cookies = moan_config.get('url-politica-de-cookies', '')
|
||||
|
||||
cookie_consent = book.get('cookie-consent', {})
|
||||
|
||||
# Atualizando o valor de 'policy-url'
|
||||
cookie_consent['policy-url'] = politica_de_cookies
|
||||
|
||||
data = metadados_html.get('data', metadados_pdf.get('data', ''))
|
||||
partes = data.split("/")
|
||||
|
||||
# Reorganizando as partes da data
|
||||
data_formatada = partes[2] + "-" + partes[1] + "-" + partes[0]
|
||||
|
||||
|
||||
# Atualizar sidebar.tools
|
||||
sidebar = book.get("sidebar", {})
|
||||
tools = sidebar.get("tools", [])
|
||||
|
||||
# Pegar o output_dir para HTML e montar URL_LIVRO
|
||||
output_dir_html = output_dirs.get("html", "")
|
||||
URL_LIVRO = output_dir_html
|
||||
|
||||
# Garantir que seja lista
|
||||
if not isinstance(tools, list):
|
||||
tools = []
|
||||
|
||||
git_item = {
|
||||
"icon": "bi bi-git",
|
||||
"text": "Alterações e Versões",
|
||||
"href": f"https://gitea.livro.online/editoramoan/{URL_LIVRO}/commits/branch/main",
|
||||
}
|
||||
|
||||
# Inserir na segunda posição
|
||||
if len(tools) >= 1:
|
||||
tools.insert(1, git_item)
|
||||
else:
|
||||
tools.append(git_item)
|
||||
|
||||
sidebar["tools"] = tools
|
||||
book["sidebar"] = sidebar
|
||||
|
||||
|
||||
|
||||
status = metadados_html.get('status', 'indisponível')
|
||||
|
||||
book.update({
|
||||
'site-url': site_url,
|
||||
'status': status,
|
||||
'isbn': metadados_html.get('isbn', metadados_pdf.get('isbn', '')),
|
||||
'title': metadados.get('título', ''),
|
||||
'subtitle': metadados.get('subtítulo', ''),
|
||||
'author': metadados.get('autor', ''),
|
||||
'description': metadados.get('descrição', ''),
|
||||
'language': metadados.get('idioma', ''),
|
||||
'publisher': metadados.get('editora', ''),
|
||||
'edition': metadados.get('edição', ''),
|
||||
'editor': metadados.get('editor', ''),
|
||||
'date': data_formatada,
|
||||
'publisher-place': metadados.get('local', ''),
|
||||
'license': metadados.get('licença', ''),
|
||||
'cookie-consent': cookie_consent
|
||||
})
|
||||
|
||||
# Salvar as alterações em _quarto.yml
|
||||
save_yaml_file(quarto_data, '_quarto.yml')
|
||||
|
||||
|
||||
# Pegar ficha catalográfica e verificar se é publicação independente ou não
|
||||
|
||||
ficha = moan_config.get('ficha-catalográfica', {})
|
||||
|
||||
# Abrir o arquivo _quarto-pdf.yml e carregar seu conteúdo
|
||||
dados = load_yaml_file("_quarto-pdf.yml")
|
||||
|
||||
# Verificar se há a chave 'ficha-catalográfica'
|
||||
if 'ficha-catalográfica' in dados:
|
||||
# Se existir, substituir seu valor pelo valor de 'ficha'
|
||||
dados['ficha-catalográfica'] = ficha
|
||||
else:
|
||||
# Se não houver, criar a chave e atribuir o valor de 'ficha' a ela
|
||||
dados['ficha-catalográfica'] = ficha
|
||||
|
||||
dados['possui-editora'] = moan_config.get('possui-editora', 'false')
|
||||
|
||||
save_yaml_file(dados, "_quarto-pdf.yml")
|
||||
Executable
+504
@@ -0,0 +1,504 @@
|
||||
import os
|
||||
import yaml
|
||||
from bs4 import BeautifulSoup
|
||||
import json
|
||||
import copy
|
||||
import shutil
|
||||
|
||||
# Caminho para o arquivo _quarto.yml
|
||||
quarto_config_file = "_quarto.yml"
|
||||
|
||||
# Caminho para o arquivo _quarto-html.yml
|
||||
quarto_html_config_file = "_quarto-html.yml"
|
||||
|
||||
|
||||
|
||||
|
||||
with open(quarto_config_file) as f:
|
||||
|
||||
quarto_config = yaml.safe_load(f)
|
||||
|
||||
|
||||
with open(quarto_html_config_file) as f:
|
||||
|
||||
quarto_html_config = yaml.safe_load(f)
|
||||
|
||||
|
||||
# Extrair as informações do arquivo _quarto.yml
|
||||
|
||||
|
||||
# funcao para iterar os capítulos
|
||||
def extrair_arquivos_qmd(objeto, capitulos_arquivos_html):
|
||||
|
||||
if isinstance(objeto, list):
|
||||
|
||||
for elemento in objeto:
|
||||
|
||||
extrair_arquivos_qmd(elemento, capitulos_arquivos_html)
|
||||
|
||||
elif isinstance(objeto, dict):
|
||||
|
||||
if 'part' in objeto:
|
||||
|
||||
extrair_arquivos_qmd(objeto['part'], capitulos_arquivos_html)
|
||||
|
||||
if 'chapters' in objeto:
|
||||
|
||||
extrair_arquivos_qmd(objeto['chapters'], capitulos_arquivos_html)
|
||||
|
||||
elif isinstance(objeto, str) and objeto.endswith('.qmd'):
|
||||
|
||||
capitulos_arquivos_html.append(objeto[:-4])
|
||||
|
||||
|
||||
|
||||
|
||||
# pegando o local dos arquivos html
|
||||
pasta_livro_renderizado = quarto_html_config["project"]["output-dir"]
|
||||
|
||||
|
||||
# pegando o campo controle-moan para verificar se é um dicionário
|
||||
é_dicionário = quarto_config["controle-moan"]["dicionario"]
|
||||
|
||||
|
||||
# pegando os capítulos
|
||||
capitulos = quarto_html_config["book"]["chapters"]
|
||||
capitulos_arquivo_html = []
|
||||
extrair_arquivos_qmd(capitulos, capitulos_arquivo_html)
|
||||
|
||||
|
||||
# Onde ficarao as referencias dos capítulos
|
||||
ref_cap = {}
|
||||
|
||||
|
||||
# Letras para 'numerar' os capítulos
|
||||
letras = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'O', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
||||
|
||||
total_de_letras = len(letras)
|
||||
|
||||
letras_index_digito_1 = 0
|
||||
|
||||
# ver qual é a próxima letra para um capítulo nao numerado
|
||||
def escolher_letra_para_capitulo(letras_index_digito_1):
|
||||
|
||||
cap = letras[letras_index_digito_1%total_de_letras]
|
||||
|
||||
# verifica se o cap precisa de um segundo digito
|
||||
if letras_index_digito_1/total_de_letras >= 1:
|
||||
|
||||
# as duas barras // de divisao pega só a parte inteira da divisao
|
||||
letras_index_digito_2 = (letras_index_digito_1 // total_de_letras) - 1
|
||||
|
||||
cap = letras[letras_index_digito_2%total_de_letras] + letras[letras_index_digito_1%total_de_letras]
|
||||
|
||||
return cap
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# altera os arquivos html
|
||||
for index, output_file in enumerate(capitulos_arquivo_html):
|
||||
|
||||
# Caminho completo para o arquivo HTML
|
||||
arquivo_html = os.path.join(pasta_livro_renderizado, output_file + ".html")
|
||||
|
||||
# conta os elementos que serão uma referencia / Ele começa em 0 na abertura de um novo capítulo
|
||||
ref_num = 0
|
||||
|
||||
# Abre o arquivo HTML
|
||||
with open(arquivo_html, "r", encoding="utf-8") as f:
|
||||
|
||||
content = f.read()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# função colocar as referencias nas tags
|
||||
def colocar_referencia(cap, el, ref):
|
||||
|
||||
# Se a tag tem id, apenas pega o valor e coloca no título da tag e defini unidade_bool false. Se não, cria o id, tb coloca no título da tag e coloca unidade_bool true
|
||||
if el.get("id"):
|
||||
|
||||
el['title'] = el['id']
|
||||
|
||||
unidade_bool = False
|
||||
|
||||
|
||||
else:
|
||||
|
||||
# Define o id da referência
|
||||
el['id'] = f"{cap}P{ref}"
|
||||
|
||||
# adiciona o title da referência
|
||||
el['title'] = f"{cap}P{ref}"
|
||||
|
||||
unidade_bool = True
|
||||
|
||||
|
||||
|
||||
# Se unidade_bool for true, adiciona a classe unidade; caso contrário, adiciona a classe unidade_silenciosa. Isso caso a tag já nao possua essas classes
|
||||
if unidade_bool:
|
||||
|
||||
if not "unidade" in el.get("class", []):
|
||||
|
||||
el["class"] = el.get("class", []) + ["unidade"]
|
||||
|
||||
else:
|
||||
|
||||
if not "unidade_silenciosa" in el.get("class", []) and "unidade" not in el.get("class", []):
|
||||
|
||||
el["class"] = el.get("class", []) + ["unidade_silenciosa"]
|
||||
|
||||
|
||||
|
||||
|
||||
# Cria um objeto BeautifulSoup
|
||||
soup = BeautifulSoup(content, "html.parser")
|
||||
|
||||
|
||||
|
||||
# Encontre a tag 'main' no documento
|
||||
main_tag = soup.find("main")
|
||||
|
||||
|
||||
# Crie o elemento script com os metadados
|
||||
script_tag = soup.new_tag('script', data="moan-metadados")
|
||||
script_tag.string = f'var metadados = {{livroUrl: "{pasta_livro_renderizado}"}}'
|
||||
|
||||
# Adicione o script ao cabeçalho (head) do HTML
|
||||
soup.head.append(script_tag)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Se existir o ark, colocar os dados nas tags object do primeiro capítulo do livro
|
||||
if "ark" in quarto_html_config["moan-dados"] and index == 0:
|
||||
|
||||
ark = quarto_html_config["moan-dados"]["ark"]
|
||||
|
||||
# Substitua "." por "_p_" e "/" por "_b_" em 'ark'
|
||||
ark = ark.replace(".", "_p_").replace("/", "_b_")
|
||||
|
||||
# Adicione "ark_dp_" ao início de 'ark'
|
||||
ark = "ark_dp_" + ark
|
||||
|
||||
# Encontre as tags object com id "metadados_livro_yml" e "metadados_livro_json"
|
||||
obj_metadados_yml = main_tag.find("object", {"id": "metadados_livro_yml"})
|
||||
|
||||
obj_metadados_json = main_tag.find("object", {"id": "metadados_livro_json"})
|
||||
|
||||
if obj_metadados_yml and obj_metadados_json:
|
||||
|
||||
# Defina o atributo "data" das tags object
|
||||
obj_metadados_yml["data"] = "https://ark.livro.online/yaml/" + ark + ".yml"
|
||||
|
||||
obj_metadados_json["data"] = "https://ark.livro.online/json/" + ark + ".json"
|
||||
|
||||
|
||||
|
||||
# Verifique se o arquivo "postos-de-venda.json" existe
|
||||
json_file_path = "postos-de-venda.json"
|
||||
|
||||
if os.path.exists(json_file_path) and index == 0:
|
||||
|
||||
# O arquivo JSON existe, abra-o e extraia as chaves e valores
|
||||
with open(json_file_path, "r", encoding="utf-8") as json_file:
|
||||
|
||||
postos_de_venda = json.load(json_file)
|
||||
|
||||
# Crie uma nova lista não ordenada para armazenar os links
|
||||
ul = soup.new_tag("ul", id="postos-de-venda")
|
||||
|
||||
for key, value in postos_de_venda.items():
|
||||
|
||||
# Crie uma nova tag de link ("a") com a chave como texto e o valor como src
|
||||
link = soup.new_tag("a", href=value)
|
||||
|
||||
link.string = key # Define o texto do link como a chave
|
||||
|
||||
# Adicione o link como um item de lista à lista não ordenada
|
||||
li = soup.new_tag("li")
|
||||
|
||||
li.append(link)
|
||||
|
||||
ul.append(li)
|
||||
|
||||
# Encontre a tag "section" com ID "versão-impressa"
|
||||
section_versao_impressa = main_tag.find("section", id="versão-impressa")
|
||||
|
||||
if section_versao_impressa:
|
||||
|
||||
# Adicione a lista não ordenada de links à seção "versão-impressa"
|
||||
section_versao_impressa.append(ul)
|
||||
|
||||
|
||||
# Copie o arquivo JSON para a pasta especificada em "pasta_livro_renderizado"
|
||||
dest_file = os.path.join(pasta_livro_renderizado, "postos-de-venda.json")
|
||||
|
||||
shutil.copy(json_file_path, dest_file)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Definindo o capítulo
|
||||
if index == 0:
|
||||
|
||||
cap = letras[letras_index_digito_1] # É a letra A, tem que ser a letra A
|
||||
|
||||
é_um_capitulo_numerado = False
|
||||
|
||||
ref_cap[cap] = capitulos_arquivo_html[index]
|
||||
|
||||
else:
|
||||
|
||||
é_um_capitulo_numerado = False
|
||||
|
||||
é_um_capitulo_verbete = False
|
||||
|
||||
# Encontre a primeira tag <h1>
|
||||
h1_tag = soup.find('h1')
|
||||
|
||||
# Todos os capítulos devem ter uma tag <h1>
|
||||
if h1_tag:
|
||||
|
||||
# Encontre o primeiro <span> com a classe 'chapter-number' dentro da tag <h1>
|
||||
span_tag = h1_tag.find('span', class_='chapter-number')
|
||||
|
||||
# Verifique se o <span> com a classe 'chapter-number' foi encontrado dentro do <h1>
|
||||
if span_tag:
|
||||
|
||||
cap = span_tag.text
|
||||
|
||||
é_um_capitulo_numerado = True
|
||||
|
||||
ref_cap[cap] = capitulos_arquivo_html[index]
|
||||
|
||||
|
||||
|
||||
|
||||
# Verifique se há pelo menos uma tag <div> com a classe "um_capitulo", ou seja nae é capitulo de verbete caso seja um dicionario
|
||||
encontrou_um_capitulo = bool(main_tag.find('div', class_='um_capitulo'))
|
||||
|
||||
|
||||
|
||||
# Se é um capítulo normal em um dicionário e nao é um capítulo numerado, seleciona a letra para marcar o capítulo
|
||||
# Nao esquecer que deve haver uma div com as classes hidden e um_capitulo em todos os capítulos que nao forem de verbetes em um de um dicionario
|
||||
if not encontrou_um_capitulo and é_dicionário:
|
||||
|
||||
é_um_capitulo_verbete = True
|
||||
|
||||
# Coloca os marcadores nos verbetes como o nome do próprio verbete
|
||||
dt_tags = main_tag.find_all('dt')
|
||||
|
||||
for dt_tag in dt_tags:
|
||||
|
||||
# Para contar o numero de definicoes dd
|
||||
Num_dd = 0
|
||||
|
||||
texto_titulo_dt = dt_tag.text
|
||||
|
||||
texto_a_ser_sanitizado = dt_tag.text
|
||||
|
||||
dt_tag['class'] = dt_tag.get("class", []) + ["unidade", "verbete"]
|
||||
|
||||
dt_tag['title'] = texto_titulo_dt
|
||||
|
||||
id_dt_tag = (texto_a_ser_sanitizado
|
||||
|
||||
.replace(' ', '_')
|
||||
.replace('&', '_e_')
|
||||
.replace('$', '_s_')
|
||||
.replace('+', '_mais_')
|
||||
.replace(',', '_vir_')
|
||||
.replace('/', '_barra_')
|
||||
.replace(':', '_dois_pontos_')
|
||||
.replace(';', '_ponto_vir_')
|
||||
.replace('?', '_interrog_')
|
||||
.replace('=', '_igual_')
|
||||
.replace('@', '_at_')
|
||||
.replace('#', '_jv_')
|
||||
.replace('>', '_maiq_')
|
||||
.replace('<', '_menq_')
|
||||
.replace('[', '_abre_colch_')
|
||||
.replace(']', '_fecha_col_')
|
||||
.replace('{', '_abre_ch_')
|
||||
.replace('}', '_fecha_ch_')
|
||||
.replace('.', '_ponto_')
|
||||
.replace('|', '_barra_ver_')
|
||||
.replace('\\', '_barra_inv_')
|
||||
.replace('%', '_p_100_')
|
||||
.replace('^', '_acen_chapeu_')
|
||||
|
||||
)
|
||||
|
||||
dt_tag['id'] = id_dt_tag
|
||||
|
||||
|
||||
|
||||
|
||||
# Encontre o primeiro elemento irmão <dd> da tag <dt>
|
||||
dd_tag = dt_tag.find_next_sibling('dd')
|
||||
|
||||
# Itere sobre todas as tags <dd> irmãs até encontrar uma tag não <dd>
|
||||
while dd_tag and dd_tag.name == 'dd':
|
||||
|
||||
Num_dd += 1
|
||||
|
||||
dd_tag['title'] = texto_titulo_dt + " def. " + str(Num_dd)
|
||||
|
||||
dd_tag['id'] = id_dt_tag + "_def_" + str(Num_dd)
|
||||
|
||||
# Encontre o próximo elemento irmão <dd> da tag <dd>
|
||||
dd_tag = dd_tag.find_next_sibling('dd')
|
||||
|
||||
|
||||
|
||||
#verifica de há outras tags além de dt, dd, e títulos (usado para o caso de um capítulo de verbete contiver mais conteúdos)
|
||||
tags_procuradas = ['p', 'li', 'tr', 'blockquote', 'code', 'pre']
|
||||
|
||||
mais_conteudo_alem_verbetes = False
|
||||
|
||||
if é_um_capitulo_verbete and é_dicionário:
|
||||
|
||||
for tag in tags_procuradas:
|
||||
|
||||
# Verifique se a tag está presente em 'main_tag'
|
||||
if main_tag.find(tag):
|
||||
|
||||
# Verifique se a tag não tem 'nav' como pai
|
||||
if not main_tag.find(tag).find_parent("nav"):
|
||||
|
||||
mais_conteudo_alem_verbetes = True
|
||||
|
||||
break # Se ambas as condições forem atendidas, definimos como True e saímos do loop
|
||||
|
||||
|
||||
|
||||
# Verifica se nao é um capítulo sem numero e se nao for um capítulo de verbete ou se é um capitulo de verbete e se existe outro conteudo alem das definicoes dos verbetes
|
||||
if (not é_um_capitulo_numerado and not é_um_capitulo_verbete) or (é_dicionário and not é_um_capitulo_numerado and é_um_capitulo_verbete and mais_conteudo_alem_verbetes):
|
||||
|
||||
letras_index_digito_1 += 1
|
||||
|
||||
cap = escolher_letra_para_capitulo(letras_index_digito_1)
|
||||
|
||||
ref_cap[cap] = capitulos_arquivo_html[index]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Iterar sobre todas as tags dentro da tag 'main'
|
||||
for tag in main_tag.find_all(True):
|
||||
|
||||
# Verifique se a classe 'unidade' está presente nos atributos da tag
|
||||
if "unidade" in tag.get("class", []):
|
||||
|
||||
# Incrementa o número da referência
|
||||
ref_num += 1
|
||||
|
||||
# Coloca a referência na tag
|
||||
colocar_referencia(cap, tag, ref_num)
|
||||
|
||||
# Pula para a próxima tag
|
||||
continue
|
||||
|
||||
parent_tag = tag.parent
|
||||
|
||||
# Não é filho direto de 'td' ou 'li'
|
||||
if parent_tag.name not in ["td", "li", "p"]:
|
||||
|
||||
# Verifique se a tag é filha de uma tag chamada 'header' usando find_parents(). Em caso positivo, pula
|
||||
is_descendant_of_header = tag.find_parents("header")
|
||||
|
||||
if is_descendant_of_header:
|
||||
continue
|
||||
|
||||
|
||||
|
||||
# Se é um parágrafo
|
||||
if tag.name == "p" or tag.name == "tr" or tag.name == "li" or tag.name == "code" or tag.name == "blockquote" or (tag.name == "dt" and not é_um_capitulo_verbete) or (tag.name == "dd" and not é_um_capitulo_verbete) or ("quarto-video" in tag.get("class", []) and tag.name == "div") or ("callout" in tag.get("class", []) and tag.name == "div") or ("csl-entry" in tag.get("class", []) and tag.name == "div"):
|
||||
|
||||
# Incrementa o número da referência
|
||||
ref_num += 1
|
||||
|
||||
# Coloca a referência na tag
|
||||
colocar_referencia(cap, tag, ref_num)
|
||||
|
||||
# Pula para a próxima tag
|
||||
continue
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Se for criado pelo usuário um id para euqacoes, aqui coloco a classe unidade_silenciosa para poder ser referenciado quando o usuário solicitar pegar referencia, mas esse tipo de referencia nao deve aparecer na paginacao do capítulo, lá no rodapé
|
||||
if "math" in tag.get("class", []) and tag.name == "span":
|
||||
|
||||
if tag.parent and tag.parent.name == "span":
|
||||
|
||||
if tag.parent.get("id"):
|
||||
|
||||
tag.parent["class"] = tag.parent.get("class", []) + ["unidade_silenciosa"]
|
||||
|
||||
tag.parent["title"] = tag.parent["id"]
|
||||
|
||||
continue
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Se tiver as classes de teoremas de matemática, colocar unidade_silenciosa
|
||||
if any(classe in tag.get("class", []) for classe in {"theorema", "lemma", "corollary", "proposition", "conjecture", "definition", "example", "exercise"}) and tag.name == "div":
|
||||
|
||||
if tag.get("id"):
|
||||
|
||||
tag["class"] = tag.parent.get("class", []) + ["unidade_silenciosa"]
|
||||
|
||||
tag["title"] = tag.parent["id"]
|
||||
|
||||
continue
|
||||
|
||||
|
||||
|
||||
# Coloca o conteudo dentro de uma div com id chamado de papel, substituindo o conteudo original da tag main pela div papel
|
||||
|
||||
# Crie uma div com id "papel"
|
||||
div_papel = soup.new_tag('div', id='papel')
|
||||
|
||||
# Copie a tag main
|
||||
main_content_copy = copy.copy(main_tag.contents)
|
||||
|
||||
# Limpe o conteúdo da tag <main>
|
||||
main_tag.clear()
|
||||
|
||||
# Adicione a cópia do conteúdo à div "papel"
|
||||
for item_copy in main_content_copy:
|
||||
div_papel.append(item_copy)
|
||||
|
||||
# Acrescentar a div_papel na tag main
|
||||
main_tag.append(div_papel)
|
||||
|
||||
# Salva o arquivo HTML modificado
|
||||
with open(arquivo_html, "w", encoding="utf-8") as f:
|
||||
|
||||
f.write(str(soup))
|
||||
|
||||
# Gravar os marcadores de referencia do livro em um arquivo JSON. ele esta na variavel ref_cap e essa informacao será útil para o leitor do livro poder entrar na busca digitar a referenci e obter o conteudo.
|
||||
nome_arquivo = "ref_capitulos.json"
|
||||
|
||||
caminho_arquivo = os.path.join(pasta_livro_renderizado, nome_arquivo)
|
||||
|
||||
with open(caminho_arquivo, "w", encoding="utf-8") as arquivo_json:
|
||||
|
||||
json.dump(ref_cap, arquivo_json, ensure_ascii=False, indent=4)
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
function Div(el)
|
||||
if el.classes:includes("qrcode") then
|
||||
|
||||
-- Nome da pasta onde estão os arquivos qr code
|
||||
local folder_name = "qr_code"
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
{ Div = Div }
|
||||
}
|
||||
@@ -0,0 +1,744 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0" class="in-text" initialize="false" demote-non-dropping-particle="never" default-locale="pt-BR">
|
||||
<info>
|
||||
<!-- ESTE ESTILO FOI CONSTRUÍDO A PARTIR DO MODELO DA ABNT (com diversos ajustes, mas os créditos permanecem aos autores originais) -->
|
||||
<title>Universidade Estadual de Alagoas - UNEAL [ABNT] (Portuguese - Brazil)</title>
|
||||
<title-short>UNEAL-ABNT</title-short>
|
||||
<id>http://www.zotero.org/styles/universidade-estadual-de-alagoas-abnt</id>
|
||||
<link href="http://www.zotero.org/styles/universidade-estadual-de-alagoas-abnt" rel="self"/>
|
||||
<link href="http://www.zotero.org/styles/associacao-brasileira-de-normas-tecnicas" rel="template"/>
|
||||
<link href="https://www.abntcatalogo.com.br/norma.aspx?ID=408006" rel="documentation"/>
|
||||
<author>
|
||||
<name>Wellyngton Chaves Monteiro da Silva</name>
|
||||
<email>[email protected]</email>
|
||||
<uri>http://www.uneal.edu.br</uri>
|
||||
</author>
|
||||
<category citation-format="author-date"/>
|
||||
<category field="generic-base"/>
|
||||
<summary>De acordo com ABNT-NBR 10520.2002 e ABNT-NBR 6023.2018</summary>
|
||||
<updated>2022-06-26T01:48:46+00:00</updated>
|
||||
<rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
|
||||
</info>
|
||||
<locale xml:lang="pt-BR">
|
||||
<!--
|
||||
UTILITÁRIOS (para serem inseridos no campo EXTRA do Zotero):
|
||||
publisher-place: quando não existir espaço para LUGAR da publicação (ex.: publisher-place: Maceió OU QUANDO NECESSÁRIO, publisher-place: Maceió, AL)
|
||||
-->
|
||||
<terms>
|
||||
<!--Abreviações dos meses do ano -->
|
||||
<term name="month-01" form="short">jan.</term>
|
||||
<term name="month-02" form="short">fev.</term>
|
||||
<term name="month-03" form="short">mar.</term>
|
||||
<term name="month-04" form="short">abr.</term>
|
||||
<term name="month-05" form="short">maio</term>
|
||||
<term name="month-06" form="short">jun.</term>
|
||||
<term name="month-07" form="short">jul.</term>
|
||||
<term name="month-08" form="short">ago.</term>
|
||||
<term name="month-09" form="short">set.</term>
|
||||
<term name="month-10" form="short">out.</term>
|
||||
<term name="month-11" form="short">nov.</term>
|
||||
<term name="month-12" form="short">dez.</term>
|
||||
<!--Os termos abaixo serao utilizados quando houverem nomes de editores. Apos a citacao dos nomes, eles irao aparecer entre parenteses.-->
|
||||
<term name="and">e</term>
|
||||
<term name="editor" form="short">
|
||||
<single>ed</single>
|
||||
<multiple>eds</multiple>
|
||||
</term>
|
||||
<term name="editor" form="short">
|
||||
<single>org</single>
|
||||
<multiple>org</multiple>
|
||||
</term>
|
||||
<term name="container-author" form="short">
|
||||
<single>ed</single>
|
||||
<multiple>eds</multiple>
|
||||
</term>
|
||||
<term name="collection-editor" form="short">
|
||||
<single>org</single>
|
||||
<multiple>org</multiple>
|
||||
</term>
|
||||
</terms>
|
||||
</locale>
|
||||
<!--A macro 'container-contributor' mostra os nomes dos editores, SOBRENOME, INICIAIS PRENOMES, sendo as inicias separadas por ponto -->
|
||||
<macro name="container-contributors">
|
||||
<choose>
|
||||
<if type="chapter">
|
||||
<names variable="container-author" delimiter=", ">
|
||||
<name name-as-sort-order="all" sort-separator=", " initialize-with=". " delimiter="; " delimiter-precedes-last="always">
|
||||
<name-part name="family" text-case="uppercase"/>
|
||||
<name-part name="given" text-case="capitalize-first"/>
|
||||
</name>
|
||||
<label form="short" prefix=" (" suffix=".)"/>
|
||||
<substitute>
|
||||
<names variable="editor"/>
|
||||
<names variable="collection-editor"/>
|
||||
</substitute>
|
||||
</names>
|
||||
</if>
|
||||
</choose>
|
||||
</macro>
|
||||
<!--A macro 'secondary-contributors' mostra os nomes dos organizadores, SOBRENOME, INICIAIS PRENOMES, sendo as inicias separadas por ponto -->
|
||||
<macro name="secondary-contributors">
|
||||
<choose>
|
||||
<if type="chapter" match="none">
|
||||
<names variable="editor" delimiter="; " prefix=" (" suffix=")">
|
||||
<name initialize-with=". " delimiter=", "/>
|
||||
<label form="short" prefix=", " text-case="capitalize-first" suffix="."/>
|
||||
</names>
|
||||
</if>
|
||||
</choose>
|
||||
</macro>
|
||||
<!--A macro 'translator' mostra os nomes dos tradutores, conforme a NBR 6023, de 2018 -->
|
||||
<macro name="translator">
|
||||
<text value="Tradução "/>
|
||||
<names variable="translator" delimiter=", ">
|
||||
<name delimiter=", " sort-separator=" " delimiter-precedes-last="always">
|
||||
<name-part name="given"/>
|
||||
<name-part name="family" text-case="capitalize-first"/>
|
||||
</name>
|
||||
<et-al font-style="normal"/>
|
||||
</names>
|
||||
</macro>
|
||||
<!--A macro 'author' mostra os nomes dos autores na bibliografia, SOBRENOME, INICIAIS PRENOMES, sendo as iniciais
|
||||
separadas por ponto. Quando houver mais de três autores, somente o primeiro será exibido e no lugar dos outros
|
||||
aparecera a expessão 'et al.'. Na regra da ABNT essa expressão deve aparecer em fonte normal -->
|
||||
<macro name="author">
|
||||
<names variable="author">
|
||||
<name name-as-sort-order="all" sort-separator=", " initialize-with=". " delimiter="; " delimiter-precedes-last="always">
|
||||
<name-part name="family" text-case="uppercase"/>
|
||||
<name-part name="given" text-case="capitalize-first"/>
|
||||
</name>
|
||||
<label form="short" prefix=" (" suffix=".)" text-case="uppercase"/>
|
||||
<substitute>
|
||||
<names variable="editor"/>
|
||||
<text macro="title"/>
|
||||
</substitute>
|
||||
</names>
|
||||
</macro>
|
||||
<!--A macro 'author-short' mostra os nomes dos autores na citação (no meio do texto). Nela aparecera apenas o último nome
|
||||
do autor. Na regra da ABNT o sobrenome deve aparecer com todas as letras em caixa alta -->
|
||||
<macro name="author-short">
|
||||
<names variable="author">
|
||||
<name form="short" name-as-sort-order="all" sort-separator=", " initialize-with=". " delimiter="; " delimiter-precedes-last="never">
|
||||
<name-part name="family" text-case="uppercase"/>
|
||||
<name-part name="given" text-case="uppercase"/>
|
||||
</name>
|
||||
<substitute>
|
||||
<names variable="editor"/>
|
||||
<choose>
|
||||
<if type="book">
|
||||
<text variable="title" form="short"/>
|
||||
</if>
|
||||
<else>
|
||||
<text variable="title" form="short" text-case="uppercase" quotes="false"/>
|
||||
</else>
|
||||
</choose>
|
||||
</substitute>
|
||||
</names>
|
||||
</macro>
|
||||
<macro name="director">
|
||||
<names variable="author">
|
||||
<name sort-separator=", " initialize-with=". " delimiter="; " delimiter-precedes-last="always">
|
||||
<name-part name="given" text-case="capitalize-first"/>
|
||||
<name-part name="family" text-case="capitalize-first"/>
|
||||
</name>
|
||||
</names>
|
||||
</macro>
|
||||
<!--A macro 'access' é utilizada em arquivos de páginas da web. Ela é responsável por exibir a URL do site pesquisado e a data do acesso, além do DOI -->
|
||||
<macro name="access">
|
||||
<text variable="ISSN" prefix=" ISSN: " suffix="."/>
|
||||
<text variable="ISBN" prefix=" ISBN: " suffix="."/>
|
||||
<text variable="DOI" prefix=" DOI: " suffix="."/>
|
||||
<!-- <text variable="URL" prefix=" Disponível em: <" suffix=">."/> RETIREI AS ENTRADAS DAS URLs, CONFORME ABNT -->
|
||||
<text variable="URL" prefix=" Disponível em: " suffix="."/>
|
||||
<date variable="accessed" prefix=". Acesso em: " suffix=".">
|
||||
<date-part name="day" suffix=" "/>
|
||||
<date-part name="month" form="short" suffix=". " text-case="lowercase"/>
|
||||
<date-part name="year"/>
|
||||
</date>
|
||||
</macro>
|
||||
<!--A macro 'title' mostra o título principal do arquivo. Em todos os tipos ele aparecerá em negrito logo após os nomes dos autores,
|
||||
exceto em arquivos do tipo 'artigo de jornal, artigo de revista, artigo de periódico', nesses arquivos eles irão aparecer em fonte normal -->
|
||||
<macro name="title">
|
||||
<choose>
|
||||
<if type="chapter article-newspaper legislation article-magazine article-journal bill entry-encyclopedia paper-conference" match="any">
|
||||
<text variable="title"/>
|
||||
</if>
|
||||
<else-if type="book thesis patent report" match="any">
|
||||
<text variable="title" font-weight="bold"/>
|
||||
</else-if>
|
||||
<else-if type="dataset" match="any">
|
||||
<text variable="title" suffix=". "/>
|
||||
</else-if>
|
||||
<else-if type="broadcast motion_picture" match="any">
|
||||
<text variable="title" text-case="uppercase"/>
|
||||
</else-if>
|
||||
<else>
|
||||
<text variable="title" font-weight="bold"/>
|
||||
</else>
|
||||
</choose>
|
||||
<text value=""/>
|
||||
</macro>
|
||||
<!-- Titulo dos Anais-->
|
||||
<macro name="container-title">
|
||||
<choose>
|
||||
<if type="paper-conference" match="any">
|
||||
<text variable="container-title" text-case="uppercase"/>
|
||||
<text variable="number" prefix=", " suffix=", "/>
|
||||
<text macro="issued-year" prefix=" " suffix=", "/>
|
||||
<text variable="publisher-place" suffix=". "/>
|
||||
<text value="Anais" font-weight="bold"/>
|
||||
<text value=" [...]. "/>
|
||||
</if>
|
||||
<else>
|
||||
<text variable="container-title" font-weight="bold"/>
|
||||
</else>
|
||||
</choose>
|
||||
</macro>
|
||||
<!--A macro 'publisher' mostra o nome da editora responsável pela publicação-->
|
||||
<macro name="publisher">
|
||||
<choose>
|
||||
<if match="any" variable="publisher-place publisher">
|
||||
<choose>
|
||||
<if variable="publisher-place">
|
||||
<text variable="publisher-place"/>
|
||||
</if>
|
||||
<else-if type="entry-encyclopedia thesis" match="any"/>
|
||||
<else-if type="paper-conference" match="any">
|
||||
<text variable="publisher-place" suffix=". "/>
|
||||
</else-if>
|
||||
<else>
|
||||
<text value="[s.l.] "/>
|
||||
</else>
|
||||
</choose>
|
||||
<choose>
|
||||
<if variable="publisher">
|
||||
<text variable="publisher" prefix=": " suffix=","/>
|
||||
<text macro="issued"/>
|
||||
</if>
|
||||
</choose>
|
||||
</if>
|
||||
<else>
|
||||
<text value="[s.l.: s.n.]"/>
|
||||
</else>
|
||||
</choose>
|
||||
</macro>
|
||||
<!--A macro 'event' sera utilizada em arquivos do tipo Evento/Conferencia. Ela e responsavel por mostrar o nome da conferencia, que tera formatacao
|
||||
em caixa alta. Utiliza-se antes do nome da conferencia a expressao "In". Segundo a regra da ABNT ela deve ser em fonte normal-->
|
||||
<macro name="event">
|
||||
<choose>
|
||||
<if variable="event">
|
||||
<choose>
|
||||
<if variable="genre" match="none">
|
||||
<text term="in" font-style="italic" text-case="capitalize-first" suffix=": "/>
|
||||
<text variable="event" text-case="uppercase"/>
|
||||
</if>
|
||||
<else>
|
||||
<group delimiter=" ">
|
||||
<text variable="genre" text-case="capitalize-first"/>
|
||||
<text term="presented at"/>
|
||||
<text variable="event"/>
|
||||
</group>
|
||||
</else>
|
||||
</choose>
|
||||
</if>
|
||||
<else-if type="paper-conference" match="any"/>
|
||||
</choose>
|
||||
</macro>
|
||||
<!--A macro 'issued' e utilizada quando devemos mostrar a data completa exemplo: 03 mar. 2011.-->
|
||||
<macro name="issued">
|
||||
<choose>
|
||||
<if variable="issued" match="any">
|
||||
<group>
|
||||
<date variable="issued">
|
||||
<date-part name="year" prefix=" " suffix=""/>
|
||||
<!-- RETIREI O PONTO DO suffix PARA FICAR 2017a, 2017b, COM PONTO FICA 2017. a., 2017. b. -->
|
||||
</date>
|
||||
</group>
|
||||
</if>
|
||||
<else-if type="patent" match="any">
|
||||
<date form="numeric" variable="issued" suffix="."/>
|
||||
</else-if>
|
||||
<else>
|
||||
<text value="[s.d.]"/>
|
||||
</else>
|
||||
</choose>
|
||||
</macro>
|
||||
<!--A macro 'issued-year' e utilizada quando desejamos que apareca apenas o ano-->
|
||||
<macro name="issued-year">
|
||||
<choose>
|
||||
<if variable="issued" match="any">
|
||||
<date variable="issued">
|
||||
<date-part name="year"/>
|
||||
</date>
|
||||
</if>
|
||||
<else-if type="paper-conference" match="all">
|
||||
<date date-parts="year" form="numeric" variable="issued">
|
||||
<date-part name="year"/>
|
||||
</date>
|
||||
</else-if>
|
||||
<else>
|
||||
<text value="[s.d.]"/>
|
||||
</else>
|
||||
</choose>
|
||||
</macro>
|
||||
<macro name="issued-legislation">
|
||||
<date variable="issued">
|
||||
<date-part name="day" suffix=" "/>
|
||||
<date-part name="month" form="short" suffix=". " text-case="lowercase"/>
|
||||
<date-part name="year"/>
|
||||
</date>
|
||||
</macro>
|
||||
<!--A macro 'edition' e responsavel por mostrar o numero da edicao.-->
|
||||
<macro name="edition">
|
||||
<choose>
|
||||
<!--Se for capitulo de livro aparecera somente o numero-->
|
||||
<if type="book chapter" match="any">
|
||||
<choose>
|
||||
<if is-numeric="edition">
|
||||
<group delimiter=" ">
|
||||
<number variable="edition" form="numeric" suffix="."/>
|
||||
<text term="edition" form="short" suffix="."/>
|
||||
</group>
|
||||
</if>
|
||||
<else>
|
||||
<!--Se for outro tipo de documento aparecera o numero e depois a descricao "ed."-->
|
||||
<text variable="edition" suffix=" ed."/>
|
||||
</else>
|
||||
</choose>
|
||||
</if>
|
||||
</choose>
|
||||
</macro>
|
||||
<!--A macro 'locators' tem como funcao mostrar os dados complementares do arquivo (paginas, secao, volume, etc)-->
|
||||
<macro name="locators">
|
||||
<choose>
|
||||
<!--Se for projeto de lei mostrara o dia, mes "forma curta", ano, secao "Sec." e pagina "p."-->
|
||||
<if type="bill">
|
||||
<group prefix=". " delimiter=", ">
|
||||
<date variable="issued">
|
||||
<date-part name="day"/>
|
||||
<date-part prefix=" " name="month" form="short"/>
|
||||
<date-part prefix=" " name="year"/>
|
||||
</date>
|
||||
<text macro="section"/>
|
||||
<text variable="page" prefix="p. " suffix="."/>
|
||||
</group>
|
||||
</if>
|
||||
<!--Se for artigos de jornal, revista, etc. Aparecera o volume "v.", edicao "n." e a pagina do artigo "p."-->
|
||||
<else-if match="any" type="article-journal article-magazine article-newspaper">
|
||||
<group delimiter=", ">
|
||||
<group delimiter=", ">
|
||||
<text variable="volume" prefix="v. "/>
|
||||
<text variable="issue" prefix="n. "/>
|
||||
</group>
|
||||
<text variable="collection-title"/>
|
||||
<text variable="page" prefix="p. "/>
|
||||
</group>
|
||||
</else-if>
|
||||
<!-- Capítulo de livro -->
|
||||
<!--Se for capitulo de livro aparecera o volume "v." e a pagina "p."-->
|
||||
<else-if match="any" type="book chapter">
|
||||
<group delimiter=", ">
|
||||
<group>
|
||||
<text variable="volume" prefix="v. " suffix=". "/>
|
||||
<text variable="page" prefix="p. "/>
|
||||
<!--Inseri este campo 'extra' caso queira colocar alguma observacao, como 'nome da coleção', 'nome da série' etc. -->
|
||||
<!-- <text variable="note" prefix=". " suffix=""/> -->
|
||||
<text macro="collection-title" prefix=". (" suffix=")."/>
|
||||
<!-- AQUI INSERE A COLEÇÃO OU SÉRIE DA OBRA -->
|
||||
</group>
|
||||
</group>
|
||||
</else-if>
|
||||
</choose>
|
||||
</macro>
|
||||
<macro name="collection-title">
|
||||
<text variable="collection-title"/>
|
||||
<text variable="collection-number" prefix=" "/>
|
||||
</macro>
|
||||
<macro name="genre">
|
||||
<text variable="genre"/>
|
||||
</macro>
|
||||
<macro name="section">
|
||||
<choose>
|
||||
<if match="any" variable="section issue">
|
||||
<text variable="section"/>
|
||||
<text variable="issue"/>
|
||||
</if>
|
||||
</choose>
|
||||
</macro>
|
||||
<macro name="citation-locator">
|
||||
<group>
|
||||
<label variable="locator" form="short"/>
|
||||
<text variable="locator" prefix=" "/>
|
||||
</group>
|
||||
</macro>
|
||||
<macro name="place">
|
||||
<choose>
|
||||
<if variable="publisher-place" match="any">
|
||||
<text variable="publisher-place" suffix=", "/>
|
||||
</if>
|
||||
<else-if type="paper-conference" variable="publisher-place">
|
||||
<text variable="publisher-place" suffix=". "/>
|
||||
</else-if>
|
||||
<else>
|
||||
<text value="[S. l.]" font-style="italic" suffix=", "/>
|
||||
</else>
|
||||
</choose>
|
||||
</macro>
|
||||
<macro name="archive">
|
||||
<group>
|
||||
<text variable="archive" prefix=" "/>
|
||||
</group>
|
||||
</macro>
|
||||
<!--Citacao-->
|
||||
<!--et al. aparece a partir de 04 autores-->
|
||||
<citation et-al-min="4" et-al-use-first="1" collapse="year" disambiguate-add-year-suffix="true">
|
||||
<sort>
|
||||
<!--Puxa o autor primeiro-->
|
||||
<key macro="author"/>
|
||||
<!--Depois o ano-->
|
||||
<key variable="issued"/>
|
||||
</sort>
|
||||
<layout prefix="(" suffix=")" delimiter="; ">
|
||||
<group>
|
||||
<text suffix=", " macro="author-short"/>
|
||||
<text macro="issued-year"/>
|
||||
<text prefix=", " macro="citation-locator"/>
|
||||
</group>
|
||||
</layout>
|
||||
</citation>
|
||||
<bibliography hanging-indent="false" et-al-min="10" et-al-use-first="1" entry-spacing="1">
|
||||
<sort>
|
||||
<key macro="author"/>
|
||||
<key variable="issued"/>
|
||||
</sort>
|
||||
<layout>
|
||||
<choose>
|
||||
<!--Projeto de lei-->
|
||||
<if type="bill">
|
||||
<group>
|
||||
<!--autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Numero da lei-->
|
||||
<text variable="number" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title" suffix=". "/>
|
||||
<!--Historico em negrito-->
|
||||
<text variable="references" font-weight="bold" suffix=". "/>
|
||||
<!-- ESTE PONTO VEM ANTES DO 'EXTRA' COMO LOCAL NAS LEIS -->
|
||||
<!--Campo 'extra' caso queira colocar alguma observacao-->
|
||||
<text variable="note"/>
|
||||
<!--Dados complementares "secao, pagina"-->
|
||||
<text macro="locators" suffix=". "/>
|
||||
</group>
|
||||
</if>
|
||||
<!--Mapa-->
|
||||
<else-if type="map">
|
||||
<group>
|
||||
<!--autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title" suffix=", "/>
|
||||
<!--data-->
|
||||
<text macro="issued" suffix=". "/>
|
||||
<!--Campo 'extra' caso queira colocar alguma observacao-->
|
||||
<text variable="note" suffix=". "/>
|
||||
</group>
|
||||
</else-if>
|
||||
<!--Livro-->
|
||||
<else-if type="book">
|
||||
<group>
|
||||
<!--autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title" suffix=". "/>
|
||||
<!--Traducao INSERI DA ABNT (ver como funciona)-->
|
||||
<text macro="translator" suffix=". "/>
|
||||
<!--Edicao-->
|
||||
<text macro="edition" suffix="., "/>
|
||||
<!-- ADICIONEI A VÍRGULA PARA SEPARAR A EDIÇÃO DO LOCAL DE PUBLICAÇÃO -->
|
||||
<!--Local, data, etc-->
|
||||
<text macro="publisher" suffix=". "/>
|
||||
<text variable="number-of-pages" suffix=" p. "/>
|
||||
<!-- ADICIONA A QUANTIDADE DE PÁGINAS NA OBRA -->
|
||||
<!-- Inseri este campo 'extra' caso queira colocar alguma observacao -->
|
||||
<text variable="note" suffix=". "/>
|
||||
<text macro="collection-title" prefix="(" suffix=")."/>
|
||||
<!-- AQUI INSERE A COLEÇÃO OU SÉRIE DA OBRA -->
|
||||
<!--Dados complementares "pagina, volume"-->
|
||||
<!--<text macro="locators"/>-->
|
||||
<!-- REMOVIDO PARA EVITAR DUPLICIDADE DE INFORMAÇÃO SOBRE A SÉRIE OU COLEÇÃO DA OBRA -->
|
||||
<text macro="access"/>
|
||||
</group>
|
||||
</else-if>
|
||||
<!--Conferencia-->
|
||||
<else-if type="chapter">
|
||||
<group>
|
||||
<!--autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title" suffix=". "/>
|
||||
<!--INSERI DA ABNT (ver como funciona) -->
|
||||
<text macro="secondary-contributors" suffix=". "/>
|
||||
<!--In:-->
|
||||
<text term="in" font-style="italic" text-case="capitalize-first" suffix=": "/>
|
||||
<!--Nomes de editores-->
|
||||
<text macro="container-contributors" suffix=". "/>
|
||||
<!--Titulo da conferencia-->
|
||||
<text macro="container-title" suffix=". "/>
|
||||
<!--Traducao INSERI DA ABNT (ver como funciona) -->
|
||||
<text macro="translator" suffix=". "/>
|
||||
<!-- <text variable="collection-title" suffix=" "/> AQUI INSERIA A SÉRIE OU COLEÇÃO DENTRO DO TEXTO -->
|
||||
<!--Edicao-->
|
||||
<text macro="edition" suffix="., "/>
|
||||
<!-- A VÍRGULA QUE SEPARA A EDIÇÃO DO LOCAL DA OBRA -->
|
||||
<!--Local, data, etc-->
|
||||
<text macro="publisher" suffix=". "/>
|
||||
<!--Dados complementares "pagina, volume"-->
|
||||
<text macro="locators" suffix=". "/>
|
||||
<text macro="access"/>
|
||||
</group>
|
||||
</else-if>
|
||||
<!--Artigo de revista, jornal, etc-->
|
||||
<else-if type="article-newspaper article-magazine article-journal" match="any">
|
||||
<group>
|
||||
<!--Autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo do artigo-->
|
||||
<text macro="title" suffix=". "/>
|
||||
<!--Titulo da publicacao-->
|
||||
<text macro="container-title" suffix=", "/>
|
||||
<!--Titulo da serie-->
|
||||
<text macro="collection-title" suffix=". "/>
|
||||
<text macro="place"/>
|
||||
<!--Edicao-->
|
||||
<text macro="edition" suffix=", "/>
|
||||
<!--Dados complementares "pagina, volume"-->
|
||||
<text macro="locators" suffix=", "/>
|
||||
<!--Data-->
|
||||
<text macro="issued" suffix=". "/>
|
||||
<text macro="access"/>
|
||||
</group>
|
||||
</else-if>
|
||||
<!--Tese-->
|
||||
<else-if type="thesis">
|
||||
<group>
|
||||
<!--Autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title" suffix=". "/>
|
||||
<text macro="issued-year" suffix=". "/>
|
||||
<text variable="number-of-pages" suffix=" f. "/>
|
||||
<!-- INSERINDO FOLHAS DE DISSERTAÇÕES E TESES -->
|
||||
<!--Tipo-->
|
||||
<text macro="genre" suffix=" - "/>
|
||||
<!--Local, data, etc-->
|
||||
<text variable="publisher" suffix=", "/>
|
||||
<text macro="place"/>
|
||||
<text macro="issued" suffix="."/>
|
||||
<text macro="access"/>
|
||||
</group>
|
||||
</else-if>
|
||||
<!-- Nao ha norma ABNT para manuscritos -->
|
||||
<else-if type="manuscript">
|
||||
<group>
|
||||
<!--Autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title" suffix=". "/>
|
||||
<!--Edicao-->
|
||||
<text macro="edition" suffix=". "/>
|
||||
<text macro="place"/>
|
||||
<!-- RETIREI O suffix=", " pois não aparece na publicação -->
|
||||
<!--Data-->
|
||||
<text macro="issued" suffix=". "/>
|
||||
<!--URL, data do acesso-->
|
||||
<text macro="access" suffix=". "/>
|
||||
<!--Arquive-->
|
||||
<text macro="archive" suffix=". "/>
|
||||
</group>
|
||||
</else-if>
|
||||
<!--Pagina da WEB-->
|
||||
<else-if type="webpage">
|
||||
<group>
|
||||
<!--Autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title" suffix=". "/>
|
||||
<text macro="genre" suffix=". "/>
|
||||
<text macro="issued-year" suffix="."/>
|
||||
<!--URL, data do acesso-->
|
||||
<text macro="access" suffix=". "/>
|
||||
</group>
|
||||
</else-if>
|
||||
<!--Relatorio-->
|
||||
<else-if type="report">
|
||||
<group>
|
||||
<!--Autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title"/>
|
||||
<!--Nomes de editores-->
|
||||
<text macro="container-contributors"/>
|
||||
<text macro="secondary-contributors"/>
|
||||
<!--Titulo da publicacao-->
|
||||
<text macro="container-title"/>
|
||||
<text variable="collection-title" prefix=": "/>
|
||||
<!--Dados complementares "pagina, volume"-->
|
||||
<text macro="locators"/>
|
||||
<!--Nome do evento, conferencia-->
|
||||
<text macro="event"/>
|
||||
<!--Local, data, etc-->
|
||||
<text macro="publisher" prefix=". " suffix=". "/>
|
||||
<!--URL, data do acesso-->
|
||||
<text macro="access" suffix="."/>
|
||||
</group>
|
||||
</else-if>
|
||||
<!--Texto para Discussao (Verbete de Dicionario)-->
|
||||
<else-if type="entry-dictionary">
|
||||
<group>
|
||||
<!--Autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title"/>
|
||||
<!--Nomes de editores-->
|
||||
<text macro="container-contributors"/>
|
||||
<text macro="secondary-contributors"/>
|
||||
<!--Titulo da publicacao-->
|
||||
<text macro="container-title"/>
|
||||
<text variable="collection-title" prefix=": " suffix=". "/>
|
||||
<!--Dados complementares "pagina, volume"-->
|
||||
<text macro="locators"/>
|
||||
<!--Nome do evento, conferencia-->
|
||||
<text macro="event"/>
|
||||
<!--Local, data, etc-->
|
||||
<text macro="publisher" prefix=". " suffix=". "/>
|
||||
<text macro="collection-title" prefix="(Texto para discussao, n. " suffix=")."/>
|
||||
<!--URL, data do acesso-->
|
||||
<text macro="access"/>
|
||||
</group>
|
||||
</else-if>
|
||||
<!--Nota Tecnica (Verbete de Enciclopedia)-->
|
||||
<else-if type="entry-encyclopedia">
|
||||
<group>
|
||||
<!--Autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title" suffix=". "/>
|
||||
<text term="in" font-style="italic" text-case="capitalize-first" suffix=": "/>
|
||||
<text macro="container-title" suffix="."/>
|
||||
<!--Local-->
|
||||
<text variable="publisher-place" prefix=". " suffix=": "/>
|
||||
<!--Editor-->
|
||||
<text variable="publisher"/>
|
||||
<!--Data-->
|
||||
<text macro="issued" prefix="," suffix=". "/>
|
||||
</group>
|
||||
</else-if>
|
||||
<!--Publicacao em conferencia-->
|
||||
<else-if type="paper-conference">
|
||||
<!--Autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title" suffix="."/>
|
||||
<text term="in" font-style="italic" text-case="capitalize-first" prefix=" " suffix=": "/>
|
||||
<!--Nomes de editores -->
|
||||
<text macro="container-contributors" text-case="uppercase"/>
|
||||
<text macro="secondary-contributors"/>
|
||||
<!--Titulo da publicacao-->
|
||||
<text macro="container-title"/>
|
||||
<!--Dados complementares "pagina, volume"-->
|
||||
<text macro="locators"/>
|
||||
<group delimiter=". " prefix=". " suffix=". ">
|
||||
<!--Nome do evento, conferencia-->
|
||||
<text macro="event"/>
|
||||
</group>
|
||||
<text macro="publisher"/>
|
||||
<text variable="page" prefix=" p. " suffix="."/>
|
||||
<text macro="access"/>
|
||||
</else-if>
|
||||
<else-if type="legislation legal_case" match="any">
|
||||
<group>
|
||||
<!--Autor-->
|
||||
<text macro="author" suffix=". "/>
|
||||
<!--Titulo-->
|
||||
<text macro="title"/>
|
||||
<text variable="abstract" prefix=". " suffix=". "/>
|
||||
<!--Titulo da publicacao-->
|
||||
<text macro="container-title" suffix=", "/>
|
||||
<text variable="publisher-place" suffix=", "/>
|
||||
<text macro="issued-legislation" suffix=". "/>
|
||||
<text macro="section" prefix="Seção " suffix=", "/>
|
||||
<text variable="page" prefix="p. " suffix="."/>
|
||||
<text macro="access"/>
|
||||
</group>
|
||||
</else-if>
|
||||
<else-if type="patent" match="any">
|
||||
<group>
|
||||
<text macro="author" suffix=". "/>
|
||||
<text macro="title" prefix=" "/>
|
||||
<text variable="number" prefix=", " suffix=", "/>
|
||||
<text macro="issued" suffix=". "/>
|
||||
</group>
|
||||
</else-if>
|
||||
<else-if type="interview song speech" match="any">
|
||||
<group>
|
||||
<text macro="author" suffix=". "/>
|
||||
<text macro="title" suffix=". "/>
|
||||
<text macro="publisher"/>
|
||||
<text variable="medium"/>
|
||||
</group>
|
||||
</else-if>
|
||||
<else-if type="broadcast motion_picture" match="any">
|
||||
<group>
|
||||
<text macro="title"/>
|
||||
<text value="Direção" text-case="capitalize-first" prefix=". " suffix=": "/>
|
||||
<text macro="director" suffix=". "/>
|
||||
<text macro="publisher"/>
|
||||
<text variable="medium"/>
|
||||
<text macro="access"/>
|
||||
</group>
|
||||
</else-if>
|
||||
<else-if type="dataset" match="any">
|
||||
<group>
|
||||
<text macro="author"/>
|
||||
<text macro="title" suffix=". "/>
|
||||
<text variable="version" prefix=". "/>
|
||||
<text macro="publisher"/>
|
||||
<text variable="medium"/>
|
||||
<text macro="access"/>
|
||||
</group>
|
||||
</else-if>
|
||||
<else>
|
||||
<!-- Inserindo referências de Documentos -->
|
||||
<text macro="author" suffix=". "/>
|
||||
<text macro="title" suffix=". "/>
|
||||
<text macro="container-contributors"/>
|
||||
<text macro="secondary-contributors"/>
|
||||
<text macro="container-title"/>
|
||||
<text variable="collection-title" prefix=": " suffix="."/>
|
||||
<text macro="locators"/>
|
||||
<group delimiter=". " prefix=". " suffix=". ">
|
||||
<!--Nome do evento, conferencia-->
|
||||
<text macro="event"/>
|
||||
</group>
|
||||
<!--Local-->
|
||||
<text variable="publisher-place" suffix=" "/>
|
||||
<!--Editor-->
|
||||
<text variable="publisher" suffix=", "/>
|
||||
<!-- Neste campo 'extra' podemos inserir o local da publicação do documento -->
|
||||
<text variable="note" suffix=""/>
|
||||
<!--Data-->
|
||||
<text macro="issued" suffix=". "/>
|
||||
<!-- REMOVI O prefix=", " DO ORIGINAL -->
|
||||
<text variable="number-of-pages" suffix=" p. "/>
|
||||
<!-- INSERINDO PÁGINAS DO DOCUMENTO -->
|
||||
<text macro="section" prefix="(" suffix=") "/>
|
||||
<!-- INSERINDO INFORMAÇÕES ADICIONAIS SOBRE O DOCUMENTO, ENTRE PARÊNTESES -->
|
||||
<!--URL, data do acesso-->
|
||||
<text macro="access"/>
|
||||
<text variable="medium"/>
|
||||
</else>
|
||||
</choose>
|
||||
</layout>
|
||||
</bibliography>
|
||||
</style>
|
||||
@@ -0,0 +1,9 @@
|
||||
title: LaTeX Environment
|
||||
author: Posit Software, PBC
|
||||
version: 1.2.1
|
||||
quarto-required: ">=1.3"
|
||||
contributes:
|
||||
filters:
|
||||
- latex-environment.lua
|
||||
format:
|
||||
pdf: default
|
||||
@@ -0,0 +1,150 @@
|
||||
-- environment.lua
|
||||
-- Copyright (C) 2020 by RStudio, PBC
|
||||
|
||||
local classEnvironments = pandoc.MetaMap({})
|
||||
local classCommands = pandoc.MetaMap({})
|
||||
|
||||
-- helper that identifies arrays
|
||||
local function tisarray(t)
|
||||
local i = 0
|
||||
for _ in pairs(t) do
|
||||
i = i + 1
|
||||
if t[i] == nil then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- reads the environments
|
||||
local function readEnvironments(meta)
|
||||
local env = meta['environments']
|
||||
if env ~= nil then
|
||||
if tisarray(env) then
|
||||
-- read an array of strings
|
||||
for i, v in ipairs(env) do
|
||||
local value = pandoc.utils.stringify(v)
|
||||
classEnvironments[value] = value
|
||||
end
|
||||
else
|
||||
-- read key value pairs
|
||||
for k, v in pairs(env) do
|
||||
local key = pandoc.utils.stringify(k)
|
||||
local value = pandoc.utils.stringify(v)
|
||||
classEnvironments[key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function readCommands(meta)
|
||||
local env = meta['commands']
|
||||
if env ~= nil then
|
||||
if tisarray(env) then
|
||||
-- read an array of strings
|
||||
for i, v in ipairs(env) do
|
||||
local value = pandoc.utils.stringify(v)
|
||||
classCommands[value] = value
|
||||
end
|
||||
else
|
||||
-- read key value pairs
|
||||
for k, v in pairs(env) do
|
||||
local key = pandoc.utils.stringify(k)
|
||||
local value = pandoc.utils.stringify(v)
|
||||
classCommands[key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function readEnvsAndCommands(meta)
|
||||
readEnvironments(meta)
|
||||
readCommands(meta)
|
||||
end
|
||||
|
||||
-- use the environments from metadata to
|
||||
-- emit a custom environment for latex
|
||||
local function writeEnvironments(divEl)
|
||||
if quarto.doc.is_format("latex") then
|
||||
for k, v in pairs(classEnvironments) do
|
||||
if divEl.attr.classes:includes(k) then
|
||||
-- process this into a latex environment
|
||||
local beginEnv = '\\begin' .. '{' .. v .. '}'
|
||||
local endEnv = '\n\\end{' .. v .. '}'
|
||||
|
||||
-- check if custom options or arguments are present
|
||||
-- and add them to the environment accordingly
|
||||
local opts = divEl.attr.attributes['options']
|
||||
if opts then
|
||||
beginEnv = beginEnv .. '[' .. opts .. ']'
|
||||
end
|
||||
|
||||
local args = divEl.attr.attributes['arguments']
|
||||
if args then
|
||||
beginEnv = beginEnv .. '{' .. args .. '}'
|
||||
end
|
||||
|
||||
-- if the first and last div blocks are paragraphs then we can
|
||||
-- bring the environment begin/end closer to the content
|
||||
if #divEl.content > 0 and divEl.content[1].t == "Para" and divEl.content[#divEl.content].t == "Para" then
|
||||
table.insert(divEl.content[1].content, 1, pandoc.RawInline('tex', beginEnv .. "\n"))
|
||||
table.insert(divEl.content[#divEl.content].content, pandoc.RawInline('tex', "\n" .. endEnv))
|
||||
else
|
||||
table.insert(divEl.content, 1, pandoc.RawBlock('tex', beginEnv))
|
||||
table.insert(divEl.content, pandoc.RawBlock('tex', endEnv))
|
||||
end
|
||||
return divEl
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function buildCommandArgs(opts, format)
|
||||
local function wrap(o)
|
||||
return string.format(format, o)
|
||||
end
|
||||
local t = pandoc.List()
|
||||
for str in string.gmatch(opts, "([^"..",".."]+)") do
|
||||
t:insert(str)
|
||||
end
|
||||
return table.concat(t:map(wrap), "")
|
||||
end
|
||||
|
||||
-- use the environments from metadata to
|
||||
-- emit a custom environment for latex
|
||||
local function writeCommands(spanEl)
|
||||
if quarto.doc.is_format("latex") then
|
||||
for k, v in pairs(classCommands) do
|
||||
if spanEl.attr.classes:includes(k) then
|
||||
|
||||
-- resolve the begin command
|
||||
local beginCommand = '\\' .. pandoc.utils.stringify(v)
|
||||
local opts = spanEl.attr.attributes['options']
|
||||
local args = spanEl.attr.attributes['arguments']
|
||||
if opts then
|
||||
beginCommand = beginCommand .. buildCommandArgs(opts, "[%s]")
|
||||
end
|
||||
if args then
|
||||
beginCommand = beginCommand .. buildCommandArgs(args, "{%s}")
|
||||
end
|
||||
|
||||
local beginCommandRaw = pandoc.RawInline('latex', beginCommand .. '{')
|
||||
|
||||
-- the end command
|
||||
local endCommandRaw = pandoc.RawInline('latex', '}')
|
||||
|
||||
-- attach the raw inlines to the span contents
|
||||
local result = spanEl.content
|
||||
table.insert(result, 1, beginCommandRaw)
|
||||
table.insert(result, endCommandRaw)
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Run in two passes so we process metadata
|
||||
-- and then process the divs
|
||||
return {
|
||||
{ Meta = readEnvsAndCommands },
|
||||
{ Div = writeEnvironments, Span = writeCommands }
|
||||
}
|
||||
Reference in new issue
Block a user