This commit is contained in:
Rafael Tavares Juliani committed 2025-09-04 15:53:18 -03:00
commit 5fbf08693c
228 files changed
+51713

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
title: Lightbox
author: Posit Software, PBC
version: 0.1.9
quarto-required: ">=1.2.198"
contributes:
filters:
- lightbox.lua
+9
View File
@@ -0,0 +1,9 @@
body:not(.glightbox-mobile) div.gslide div.gslide-description,
body:not(.glightbox-mobile) div.gslide-description .gslide-title,
body:not(.glightbox-mobile) div.gslide-description .gslide-desc {
color: var(--quarto-body-color);
background-color: var(--quarto-body-bg);
}
+251
View File
@@ -0,0 +1,251 @@
-- whether we're automatically lightboxing
local auto = false
-- whether we need lightbox dependencies added
local needsLightbox = false
-- a counter used to ensure each image is in its own gallery
local imgCount = 0
-- attributes to forward from the image to the newly created link
local kDescription = "description"
local kForwardedAttr = {
"title", kDescription, "desc-position",
"type", "effect", "zoomable", "draggable"
}
local kLightboxClass = "lightbox"
local kNoLightboxClass = "nolightbox"
local kGalleryPrefix = "quarto-lightbox-gallery-"
-- A list of images already within links that we can use to filter
local imagesWithinLinks = pandoc.List({})
local function readAttrValue(el, attrName)
if attrName == kDescription then
local doc = pandoc.read(el.attr.attributes[attrName])
local attrInlines = doc.blocks[1].content
return pandoc.write(pandoc.Pandoc(attrInlines), "html")
else
return el[attrName]
end
end
return {
{
Meta = function(meta)
-- If the mode is auto, we need go ahead and
-- run if there are any images (ideally we would)
-- filter to images in the body, but that can be
-- left for future me to deal with
-- supports:
-- lightbox: auto
-- or
-- lightbox:
-- match: auto
local lbMeta = meta.lightbox
if lbMeta ~= nil and type(lbMeta) == 'table' then
if lbMeta[1] ~= nil then
if lbMeta[1]['text'] == "auto" then
auto = true
end
elseif lbMeta.match ~= nil and pandoc.utils.stringify(lbMeta.match) == 'auto' then
auto = true
elseif lbMeta == true then
auto = true
end
end
end,
-- Find images that are already within links
-- we'll use this to filter out these images if
-- the most is auto
Link = function(linkEl)
pandoc.walk_inline(linkEl, {
Image = function(imageEl)
imagesWithinLinks[#imagesWithinLinks + 1] = imageEl
end
})
end
},{
Div = function(div)
if div.classes:includes("cell") and div.attributes["lightbox"] ~= nil then
meta = quarto.json.decode(div.attributes["lightbox"])
local imgCount=0
div = div:walk({
Image = function(imgEl)
imgCount = imgCount + 1
if (type(meta) == "table" and meta[kNoLightboxClass] == true) or meta == false then
imgEl.classes:insert(kNoLightboxClass)
else
if not auto and ((type(meta) == "table" and not meta[kNoLightboxClass]) or meta == true) then
imgEl.classes:insert(kLightboxClass)
end
if (type(meta) == "table") then
if meta.group then
imgEl.attr.attributes.group = meta.group or imgEl.attr.attributes.group
end
for _, v in next, kForwardedAttr do
if type(meta[v]) == "table" and #meta[v] > 1 then
-- if list attributes it should be one per plot
if imgCount > #meta[v] then
quarto.log.warning("More plots than '" .. v .. "' passed in YAML chunk options.")
else
attrLb = meta[v][imgCount]
end
else
-- Otherwise reuse the single attributes
attrLb = meta[v]
end
imgEl.attr.attributes[v] = attrLb or imgEl.attr.attributes[v]
end
end
end
return imgEl
end
})
div.attributes["lightbox"] = nil
end
return div
end
},
{
Image = function(imgEl)
if quarto.doc.is_format("html:js") then
local isAlreadyLinked = imagesWithinLinks:includes(imgEl)
if (not isAlreadyLinked and auto and not imgEl.classes:includes(kNoLightboxClass))
or imgEl.classes:includes('lightbox') then
-- note that we need to include the dependency for lightbox
needsLightbox = true
imgCount = imgCount + 1
-- remove the class from the image
imgEl.attr.classes = imgEl.attr.classes:filter(function(clz)
return clz ~= kLightboxClass
end)
-- attributes for the link
local linkAttributes = {}
-- mark this image as a lightbox target
linkAttributes.class = kLightboxClass
-- get the alt text from image and use that as title
local title = nil
if imgEl.caption ~= nil and #imgEl.caption > 0 then
linkAttributes.title = pandoc.utils.stringify(imgEl.caption)
elseif imgEl.attributes['fig-alt'] ~= nil and #imgEl.attributes['fig-alt'] > 0 then
linkAttributes.title = pandoc.utils.stringify(imgEl.attributes['fig-alt'])
end
-- move a group attribute to the link, if present
if imgEl.attr.attributes.group ~= nil then
linkAttributes.gallery = imgEl.attr.attributes.group
imgEl.attr.attributes.group = nil
else
linkAttributes.gallery = kGalleryPrefix .. imgCount
end
-- forward any other known attributes
for i, v in ipairs(kForwardedAttr) do
if imgEl.attr.attributes[v] ~= nil then
-- forward the attribute
linkAttributes[v] = readAttrValue(imgEl, v)
-- clear the attribute
imgEl.attr.attributes[v] = nil
end
-- clear the title
if (imgEl.title == 'fig:') then
imgEl.title = ""
end
end
-- wrap decorated images in a link with appropriate attrs
local link = pandoc.Link({imgEl}, imgEl.src, nil, linkAttributes)
return link
end
end
end,
Meta = function(meta)
-- If we discovered lightbox-able images
-- we need to include the dependencies
if needsLightbox then
-- add the dependency
quarto.doc.add_html_dependency({
name = 'glightbox',
scripts = {'resources/js/glightbox.min.js'},
stylesheets = {'resources/css/glightbox.min.css', 'lightbox.css'}
})
-- read lightbox options
local lbMeta = meta.lightbox
local lbOptions = {}
local readEffect = function(el)
local val = pandoc.utils.stringify(el)
if val == "fade" or val == "zoom" or val == "none" then
return val
else
error("Invalid effect " + val)
end
end
-- permitted options include:
-- lightbox:
-- effect: zoom | fade | none
-- desc-position: top | bottom | left |right
-- loop: true | false
-- class: <class-name>
local effect = "zoom"
local descPosition = "bottom"
local loop = true
local skin = nil
-- The selector controls which elements are targeted.
-- currently, it always targets .lightbox elements
-- and there is no way for the user to change this
local selector = "." .. kLightboxClass
if lbMeta ~= nil and type(lbMeta) == 'table' then
if lbMeta.effect ~= nil then
effect = readEffect(lbMeta.effect)
end
if lbMeta['desc-position'] ~= nil then
descPosition = pandoc.utils.stringify(lbMeta['desc-position'])
end
if lbMeta['css-class'] ~= nil then
skin = pandoc.utils.stringify(lbMeta['css-class'])
end
if lbMeta.loop ~= nil then
loop = lbMeta.loop
end
end
-- Generate the options to configure lightbox
local options = {
selector = selector,
closeEffect = effect,
openEffect = effect,
descPosition = descPosition,
loop = loop,
}
if skin ~= nil then
options.skin = skin
end
local optionsJson = quarto.json.encode(options)
-- generate the initialization script with the correct options
local scriptTag = "<script>var lightboxQuarto = GLightbox(" .. optionsJson .. ");</script>"
-- inject the rendering code
quarto.doc.include_text("after-body", scriptTag)
end
end
}}
+1
View File
@@ -0,0 +1 @@
.glightbox-container{width:100%;height:100%;position:fixed;top:0;left:0;z-index:999999!important;overflow:hidden;-ms-touch-action:none;touch-action:none;-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;-ms-text-size-adjust:100%;text-size-adjust:100%;-webkit-backface-visibility:hidden;backface-visibility:hidden;outline:0}.glightbox-container.inactive{display:none}.glightbox-container .gcontainer{position:relative;width:100%;height:100%;z-index:9999;overflow:hidden}.glightbox-container .gslider{-webkit-transition:-webkit-transform .4s ease;transition:-webkit-transform .4s ease;transition:transform .4s ease;transition:transform .4s ease,-webkit-transform .4s ease;height:100%;left:0;top:0;width:100%;position:relative;overflow:hidden;display:-webkit-box!important;display:-ms-flexbox!important;display:flex!important;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.glightbox-container .gslide{width:100%;position:absolute;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;opacity:0}.glightbox-container .gslide.current{opacity:1;z-index:99999;position:relative}.glightbox-container .gslide.prev{opacity:1;z-index:9999}.glightbox-container .gslide-inner-content{width:100%}.glightbox-container .ginner-container{position:relative;width:100%;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;max-width:100%;margin:auto;height:100vh}.glightbox-container .ginner-container.gvideo-container{width:100%}.glightbox-container .ginner-container.desc-bottom,.glightbox-container .ginner-container.desc-top{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.glightbox-container .ginner-container.desc-left,.glightbox-container .ginner-container.desc-right{max-width:100%!important}.gslide iframe,.gslide video{outline:0!important;border:none;min-height:165px;-webkit-overflow-scrolling:touch;-ms-touch-action:auto;touch-action:auto}.gslide:not(.current){pointer-events:none}.gslide-image{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.gslide-image img{max-height:100vh;display:block;padding:0;float:none;outline:0;border:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;max-width:100vw;width:auto;height:auto;-o-object-fit:cover;object-fit:cover;-ms-touch-action:none;touch-action:none;margin:auto;min-width:200px}.desc-bottom .gslide-image img,.desc-top .gslide-image img{width:auto}.desc-left .gslide-image img,.desc-right .gslide-image img{width:auto;max-width:100%}.gslide-image img.zoomable{position:relative}.gslide-image img.dragging{cursor:-webkit-grabbing!important;cursor:grabbing!important;-webkit-transition:none;transition:none}.gslide-video{position:relative;max-width:100vh;width:100%!important}.gslide-video .plyr__poster-enabled.plyr--loading .plyr__poster{display:none}.gslide-video .gvideo-wrapper{width:100%;margin:auto}.gslide-video::before{content:'';position:absolute;width:100%;height:100%;background:rgba(255,0,0,.34);display:none}.gslide-video.playing::before{display:none}.gslide-video.fullscreen{max-width:100%!important;min-width:100%;height:75vh}.gslide-video.fullscreen video{max-width:100%!important;width:100%!important}.gslide-inline{background:#fff;text-align:left;max-height:calc(100vh - 40px);overflow:auto;max-width:100%;margin:auto}.gslide-inline .ginlined-content{padding:20px;width:100%}.gslide-inline .dragging{cursor:-webkit-grabbing!important;cursor:grabbing!important;-webkit-transition:none;transition:none}.ginlined-content{overflow:auto;display:block!important;opacity:1}.gslide-external{display:-webkit-box;display:-ms-flexbox;display:flex;width:100%;min-width:100%;background:#fff;padding:0;overflow:auto;max-height:75vh;height:100%}.gslide-media{display:-webkit-box;display:-ms-flexbox;display:flex;width:auto}.zoomed .gslide-media{-webkit-box-shadow:none!important;box-shadow:none!important}.desc-bottom .gslide-media,.desc-top .gslide-media{margin:0 auto;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.gslide-description{position:relative;-webkit-box-flex:1;-ms-flex:1 0 100%;flex:1 0 100%}.gslide-description.description-left,.gslide-description.description-right{max-width:100%}.gslide-description.description-bottom,.gslide-description.description-top{margin:0 auto;width:100%}.gslide-description p{margin-bottom:12px}.gslide-description p:last-child{margin-bottom:0}.zoomed .gslide-description{display:none}.glightLine truncated
+1
View File
@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).GLightbox=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}var s=Date.now();function l(){var e={},t=!0,i=0,n=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],i++);for(var s=function(i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t&&"[object Object]"===Object.prototype.toString.call(i[n])?e[n]=l(!0,e[n],i[n]):e[n]=i[n])};i<n;i++){var o=arguments[i];s(o)}return e}function o(e,t){if((k(e)||e===window||e===document)&&(e=[e]),A(e)||L(e)||(e=[e]),0!=P(e))if(A(e)&&!L(e))for(var i=e.length,n=0;n<i&&!1!==t.call(e[n],e[n],n,e);n++);else if(L(e))for(var s in e)if(O(e,s)&&!1===t.call(e[s],e[s],s,e))break}function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=e[s]=e[s]||[],l={all:n,evt:null,found:null};return t&&i&&P(n)>0&&o(n,(function(e,n){if(e.eventName==t&&e.fn.toString()==i.toString())return l.found=!0,l.evt=n,!1})),l}function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.onElement,n=t.withCallback,s=t.avoidDuplicate,l=void 0===s||s,a=t.once,h=void 0!==a&&a,d=t.useCapture,c=void 0!==d&&d,u=arguments.length>2?arguments[2]:void 0,g=i||[];function v(e){T(n)&&n.call(u,e,this),h&&v.destroy()}return C(g)&&(g=document.querySelectorAll(g)),v.destroy=function(){o(g,(function(t){var i=r(t,e,v);i.found&&i.all.splice(i.evt,1),t.removeEventListener&&t.removeEventListener(e,v,c)}))},o(g,(function(t){var i=r(t,e,v);(t.addEventListener&&l&&!i.found||!l)&&(t.addEventListener(e,v,c),i.all.push({eventName:e,fn:v}))})),v}function h(e,t){o(t.split(" "),(function(t){return e.classList.add(t)}))}function d(e,t){o(t.split(" "),(function(t){return e.classList.remove(t)}))}function c(e,t){return e.classList.contains(t)}function u(e,t){for(;e!==document.body;){if(!(e=e.parentElement))return!1;if("function"==typeof e.matches?e.matches(t):e.msMatchesSelector(t))return e}}function g(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!e||""===t)return!1;if("none"===t)return T(i)&&i(),!1;var n=x(),s=t.split(" ");o(s,(function(t){h(e,"g"+t)})),a(n,{onElement:e,avoidDuplicate:!1,once:!0,withCallback:function(e,t){o(s,(function(e){d(t,"g"+e)})),T(i)&&i()}})}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(""===t)return e.style.webkitTransform="",e.style.MozTransform="",e.style.msTransform="",e.style.OTransform="",e.style.transform="",!1;e.style.webkitTransform=t,e.style.MozTransform=t,e.style.msTransform=t,e.style.OTransform=t,e.style.transform=t}function f(e){e.style.display="block"}function p(e){e.style.display="none"}function m(e){var t=document.createDocumentFragment(),i=document.createElement("div");for(i.innerHTML=e;i.firstChild;)t.appendChild(i.firstChild);return t}function y(){return{width:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,height:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}}function x(){var e,t=document.createElement("fakeelement"),i={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(e in i)if(void 0!==t.style[e])return i[e]}function b(e,t,i,n){if(e())t();else{var s;i||(i=100);var l=setInterval((function(){e()&&(clearInterval(l),s&&clearTimeout(s),t())}),i);n&&(s=setTimeout((function(){clearInterval(l)}),n))}}function S(e,t,i){if(I(e))console.error("Inject assets error");else if(T(t)&&(i=t,t=!1),C(t)&&t in window)T(i)&&i();else{var n;if(-1!==e.indexOf(".css")){if((n=document.querySelectorAll('link[href="'+e+'"]'))&&n.length>0)return void(T(i)&&i());var s=document.getElementsByTagName("head")[0],l=s.querySelectorAll('link[rel="stylesheet"]'),o=document.createElement("link");return o.rel="stylesheet",o.type="text/css",o.href=e,o.media="all",l?s.insertBefore(o,l[0]):s.appendChild(o),void(T(i)&&i())}if((n=document.querySelectorAll('script[src="'+e+'"]'))&&n.length>0){if(T(i)){if(C(t))return b((function(){return void 0!==window[t]}),(function(){i()})),!1;i()}}else{var r=document.createElement("script");r.type="text/javascript",r.src=e,r.onload=function(){if(T(i)){if(C(t))return b((function(){return void 0!==window[t]}),(function(){i()Line truncated
+17
View File
@@ -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]
+154
View File
@@ -0,0 +1,154 @@
/*-- 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;
}
.verso, .exemplo
{
display: block;
margin: 15px auto;
width: 300px;
}
#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: 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;
}
}
+522
View File
@@ -0,0 +1,522 @@
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"
with open(quarto_config_file) as f:
quarto_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_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_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']
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%25]
# verifica se o cap precisa de um segundo digito
if letras_index_digito_1/25 >= 1:
# as duas barras // de divisao pega só a parte inteira da divisao
letras_index_digito_2 = (letras_index_digito_1 // 25) - 1
cap = letras[letras_index_digito_2%25] + letras[letras_index_digito_1%25]
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_config["moan-dados"] and index == 0:
ark = quarto_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)
# Copiar a imagem og.jpg que está na pasta img e serve para usar no open graph
# Pasta onde o arquivo og.jpg está localizado
pasta_img = "img"
# Caminho completo para o arquivo og.jpg
caminho_original = os.path.join(pasta_img, "og.jpg")
# Verifica se o arquivo og.jpg existe na pasta img
if os.path.exists(caminho_original):
# Caminho completo para a pasta de destino na pasta livro_renderizado
caminho_destino = os.path.join(pasta_livro_renderizado, "img")
# Certifica-se de que a pasta de destino exista
os.makedirs(caminho_destino, exist_ok=True)
# Copia o arquivo og.jpg para a pasta de destino
shutil.copy(caminho_original, caminho_destino)
print("Arquivo og.jpg foi copiado com sucesso.")
else:
print("O arquivo og.jpg não foi encontrado na pasta img.")
# 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)
@@ -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: &lt;" suffix="&gt;."/> 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>