Skip to content

Commit

Permalink
bug fix in HTML output
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazzpirate committed Jul 25, 2024
1 parent 7c4a4eb commit d8e2d47
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
15 changes: 8 additions & 7 deletions rustex/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub fn register_primitives_postinit(engine:&mut DefaultEngine<Types>) {
register_unexpandable(engine,"rustex@annotateTop",CommandScope::Any,annot_top);
register_unexpandable(engine,"rustex@cssLink",CommandScope::Any,css_link);
register_unexpandable(engine,"rustex@HTMLLiteral",CommandScope::Any,html_literal);
register_unexpandable(engine,"rustex@directHTML",CommandScope::Any,html_literal);
// if@rustex
// rustex@directHTML
}
Expand Down Expand Up @@ -69,11 +70,11 @@ fn namespace(engine:Refs,token:CompactToken) -> Res<()> {
Ok(())
}

fn annot_top(engine:Refs,token:CompactToken) -> Res<()> {
fn meta(engine:Refs,token:CompactToken) -> Res<()> {
let mut attrs = VecMap::default();
let mut str = String::new();
engine.read_braced_string(true,true,&token,&mut str)?;
let mut s = str[..].trim();
let top = &mut engine.aux.extension.top;
while !s.is_empty() {
let key = if let Some(i) = s.find('=') {
let (n,v) = s.split_at(i);
Expand All @@ -92,16 +93,17 @@ fn annot_top(engine:Refs,token:CompactToken) -> Res<()> {
s = r[1..].trim_start();
v.trim()
} else { todo!() };
top.insert(key.to_string(),val.to_string());
attrs.insert(key.to_string(),val.to_string());
}
engine.aux.extension.metas.push(attrs);
Ok(())
}

fn meta(engine:Refs,token:CompactToken) -> Res<()> {
let mut attrs = VecMap::default();
fn annot_top(engine:Refs,token:CompactToken) -> Res<()> {
let mut str = String::new();
engine.read_braced_string(true,true,&token,&mut str)?;
let mut s = str[..].trim();
let top = &mut engine.aux.extension.top;
while !s.is_empty() {
let key = if let Some(i) = s.find('=') {
let (n,v) = s.split_at(i);
Expand All @@ -120,9 +122,8 @@ fn meta(engine:Refs,token:CompactToken) -> Res<()> {
s = r[1..].trim_start();
v.trim()
} else { todo!() };
attrs.insert(key.to_string(),val.to_string());
top.insert(key.to_string(),val.to_string());
}
engine.aux.extension.metas.push(attrs);
Ok(())
}

Expand Down
8 changes: 4 additions & 4 deletions rustex/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ profile 1:27 ==> 1:43
thesis 0:15
*/
fn main() {
profile()
//profile()
//thesis()
//run()
run()
//test()
//temp_test()
//notes()
Expand Down Expand Up @@ -163,15 +163,15 @@ fn temp_test() {
//let ret = RusTeXEngine::do_file("/home/jazzpirate/work/Software/sTeX/RusTeXNew/test/numtest.tex",false,true,true);
let ret = RusTeXEngine::do_file(
//"/home/jazzpirate/work/MathHub/Papers/24-cicm-views-in-alea/source/ex/model-satisfies-formula-view-fol.en.tex",
"/home/jazzpirate/work/Software/sTeX/RusTeXNew/test/tmptest.tex",
"/home/jazzpirate/work/MathHub/sTeX/DemoExamples/source/quickstart.tex",
true,
true,
true,
);
//let ret = RusTeXEngine::do_file("/home/jazzpirate/work/LaTeX/Papers/17 - Alignment Translation/macros/kwarc/workplan/workplan-template.tex",true,true,true);
//std::fs::write("/home/jazzpirate/work/Software/sTeX/RusTeXNew/test/numtest.html", &ret.out).unwrap();
std::fs::write(
"/home/jazzpirate/work/Software/sTeX/RusTeXNew/test/temp_test.html",
"/home/jazzpirate/work/MathHub/sTeX/DemoExamples/source/quickstart.tex.html",
&ret.out,
)
.unwrap();
Expand Down
8 changes: 4 additions & 4 deletions rustex/src/shipout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,10 @@ fn do_mathlist(engine:Refs, state:&mut ShipoutState, children:&mut MNodes) -> Re
nodes::vrule(state,start,end,width.unwrap_or(Dim32(26214)),height,depth)
}
MathNode::Whatsit(wi) => wi.call(engine)?,
MathNode::Custom(RusTeXNode::FontChange(font,false)) => annotations::do_font(state,&engine.fontsystem.glyphmaps,font),
MathNode::Custom(RusTeXNode::FontChangeEnd) => annotations::close_font(state),
MathNode::Custom(RusTeXNode::AnnotBegin {start,attrs,styles,tag}) => annotations::do_annot(state,start,tag,attrs,styles),
MathNode::Custom(RusTeXNode::AnnotEnd(end)) => annotations::close_annot(state,end),
MathNode::Custom(RusTeXNode::FontChange(font,false)) => {flush!();annotations::do_font(state,&engine.fontsystem.glyphmaps,font)}
MathNode::Custom(RusTeXNode::FontChangeEnd) => {flush!();annotations::close_font(state)}
MathNode::Custom(RusTeXNode::AnnotBegin {start,attrs,styles,tag}) => {flush!();annotations::do_annot(state,start,tag,attrs,styles)}
MathNode::Custom(RusTeXNode::AnnotEnd(end)) => {flush!();annotations::close_annot(state,end)}
MathNode::HFil | MathNode::HFill | MathNode::Hss | MathNode::HFilneg | MathNode::Penalty(_) => (),
MathNode::Custom(RusTeXNode::PDFNode(PDFNode::PDFOutline(_) | PDFNode::PDFPageAttr(_) | PDFNode::PDFPagesAttr(_) |
PDFNode::PDFCatalog(_) | PDFNode::PDFSave | PDFNode::PDFAnnot(_) | PDFNode::PDFLiteral(_) | PDFNode::XForm(_) | PDFNode::Obj(_))) => (),
Expand Down
1 change: 1 addition & 0 deletions rustex/src/shipout/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use tex_engine::prelude::{HNode, MathNode, VNode};
use tex_engine::tex::nodes::math::MathFontStyle;
use crate::engine::Types;

#[derive(Debug)]
pub(crate) struct ExtensibleIter<T> {
curr:IntoIter<T>,
next:Vec<IntoIter<T>>
Expand Down
2 changes: 1 addition & 1 deletion rustex/src/stomach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pub fn vsplit(engine: Refs, mut nodes: Vec<VNode<Types>>, mut target: Dim32) ->
let split_penalty = match rest.first() {
Some(VNode::Penalty(p)) => {
let p = *p;
rest.remove(0);
rest.drain(..1).next();
Some(p)
}
_ => None
Expand Down
2 changes: 1 addition & 1 deletion tex_engine/src/engine/gullet/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn read_delimited_argument<ET:EngineTypes>(engine:&mut EngineReferences<ET>,arg:
if let Some(Some(n)) = remove_braces {
if arg.len() == n {
arg.pop();
arg.remove(0);
arg.drain(..1).next();
}
}
if ends_with_bgroup {
Expand Down
2 changes: 1 addition & 1 deletion tex_engine/src/engine/stomach/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ pub fn vsplit_roughly<ET:EngineTypes>(engine: &mut EngineReferences<ET>, mut nod
let split_penalty = match rest.first() {
Some(VNode::Penalty(p)) => {
let p = *p;
rest.remove(0);
rest.drain(..1).next();
Some(p)
}
_ => None
Expand Down

0 comments on commit d8e2d47

Please sign in to comment.