Specify multiple classes for ignoreClass property in MathJax configuration - mathjax

I have the following code for MathJax configuration. I would like MathJax to ignore elements that have the class im or the classes class1 class2.
Question:
Is it possible to specify a list of classes for ignoreClass property, and if yes then how would it be specified?
I have tried a comma-delimited list of classes for this property, but it did not work, i.e. I tried class1 class2 , im,
window.MathJax = {
tex2jax: {
inlineMath: [['\\$', '\\$'], ["\\(", "\\)"]],
displayMath: [['$$', '$$'], ["\\[", "\\]"]],
processEscapes: true,
ignoreClass: "class1 class2"
}
};

Related

Using full java object package paths inline in autogenerated code

We have a pretty comic situation: a Postgres DB with a schema called Internal:
public class Internal extends SchemaImpl
Now we have to create an enum, with one of the values being called... Internal. The autogenerated code for this enum doesn't compile due to the collision between the enum name and the schema name, returned by getSchema() method:
///
import blabla.jooq.internal.Internal;
///
#Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.11.12"
},
comments = "This class is generated by jOOQ"
)
#SuppressWarnings({ "all", "unchecked", "rawtypes" })
public enum TypeEnum implements EnumType {
Internal("Internal"), External("External");
/////
/**
* {#inheritDoc}
*/
#Override
public Schema getSchema() {
return Internal.INTERNAL; //<<< The compiler thinks Internal is the enum value and not the schema name static object and fails
}
The two options to fix this are:
Rename the enum (which for some reason we would like to avoid)
Make the autogenerated code have the package names being included with the object references inline
Is there any configuration that will let us achieve option 2?
TIA
Bug in the code generator
That looks like a bug in jOOQ's code generator. I've created: https://github.com/jOOQ/jOOQ/issues/13692
Work around by renaming generated objects
You can work around such bugs by using a "generator strategy":
Programmatic: https://www.jooq.org/doc/latest/manual/code-generation/codegen-generatorstrategy/
Configurative: https://www.jooq.org/doc/latest/manual/code-generation/codegen-matcherstrategy/
With such a strategy, you can rename either the schema or enum class name, or both, of course, depending on your tastes:
<configuration>
<generator>
<strategy>
<matchers>
<schemas>
<schema>
<expression>INTERNAL</expression>
<schemaClass>
<transform>PASCAL</transform>
<expression>$0_SCHEMA</expression>
</schemaClass>
</schema>
</schemas>
<enums>
<enum>
<expression>INTERNAL</expression>
<enumClass>
<transform>PASCAL</transform>
<expression>$0_ENUM</expression>
</enumClass>
</enum>
</enums>
</matchers>
</strategy>
</generator>
</configuration>
Work around by avoiding imports for certain types
Alternatively, you can specify which type references should always remain fully qualified, rather than imported, see:
https://www.jooq.org/doc/latest/manual/code-generation/codegen-advanced/codegen-config-generate/codegen-generate-fully-qualified-types/
For example:
<configuration>
<generator>
<generate>
<fullyQualifiedTypes>.*\.INTERNAL</fullyQualifiedTypes>
</generate>
</generator>
</configuration>

Reflected attributes

What's the purpose and use of passing an (internal) property change to an (external) observed attribute? Please, if possible, give an extrovert example.
Tia
One primary use case is that the attribute can then be used by CSS attribute selectors. This way you can easily do conditional styling based on a state:
:host([selected]) .foo {
background-color: gray;
}
:host([mode="foo"]) .bar {
}
Another use case can be reflecting a property to an aria attribute, interpreted by screen readers:
static get properties() {
return {
checked: {
type: Boolean,
attribute: 'aria-checked',
reflect: true,
}
};
}

Extend a view or use a mixin in Ember.js

I would like to include standard functionality in several views within an Ember app. The functionality includes things like setting the tagName and classNames of the views to be the same and keeping track of a property for each view.
The question in a nutshell: Should I use a mixin or extend a base view?
The expanded question...
Should one extend a base view to do this? For example:
App.BaseView = Em.View.extend({
tagName: 'section',
classNames: ['page_section', 'blue'],
willInsertElement: function() {
// Some functions called here that set properties
},
});
App.PageOneView = App.BaseView.extend({
// View specific stuff here
});
App.PageTwoView = App.BaseView.extend({
// View specific stuff here
});
... Or, should one use a Mixin to extend the functionality? For example:
App.BaseMixin = Em.Mixin.create({
tagName: 'section',
classNames: ['page_section', 'blue'],
willInsertElement: function() {
// Some functions called here that set properties
},
});
App.PageOneView = Em.View.extend(App.BaseMixin, {
// View specific stuff here
});
App.PageTwoView = Em.View.extend(App.BaseMixin, {
// View specific stuff here
});
I understand that views and mixins are both Ember objects, but does using either of them to extend standard functionality to other objects (e.g. views) affects how the objects and prototypes/instances (if they differ from the object) interact and whether properties get set on the instance of the view or the view object?
If the two examples above differ, would setting the properties on the mixin's init function change anything? For example:
App.BaseMixin = Em.Mixin.create({
tagName: null,
classNames: null,
init: function() {
this.set('tagName', 'section');
// And so forth...
},
});
However, if using a mixin and extending a view have the same affect on the views I am trying to add the standard functionality to (that is, they affect the views' objects and prototypes/instances in the same way), do you see an advantage to using one over the other (whether in terms of efficiency, maintainability, etc)?
Great question,
Short and simple, extend the view.
The hooks/bindings are view specific, so the mixin can't be applied to a controller, route etc, and depending on your team makeup, you don't want to give someone an opportunity to mix in code that doesn't belong.
Extending a class in Ember just makes the base class into a mixin and applies it to your class. https://github.com/emberjs/ember.js/blob/v1.2.0/packages/ember-runtime/lib/system/core_object.js#L488
So it's almost the exact same thing, only your base view makes more sense since it only really applies to views.

Using $helper in CakePHP 2

I have a question about declaring $helper explicitly.
This is sample code from CakePHP Book.
<?php
class PostsController extends AppController {
public $helpers = array('Html', 'Form');
..
}
In my code, I didn't have that declaration at all, but my app is still working, I can save data via my web form, I can also using $this->Html->link().
Do I really need that declaration, any disadvantages if I didn't?
Thanks to all.
The $helpers variable only needs to be declared when you are using a Helper other than 'HTML' and 'Form'. The core helpers 'Html' and 'Form' are loaded by default into the $helpers array, so the declaration is unnecessary if you only intend to use these.
If you want to add a custom helper, or use any other core helper, then you must declare the $helpers array. When you do this, you are overwriting the default helpers array, so you need to make sure to include the defaults again if you still intend to use them.
// Default. You do not need to declare this if you
// only intend to use these helpers.
$helpers = array('HTML', 'Form');
// Add 'CustomHelper' to $helpers array. In this case
// HTML and Form must be declared.
$helpers = array('HTML', 'Form', 'Custom');

Can I add attributes to a Backbone View?

I have been working with backbone for a while and I am now using a number of views. In some of my views I sometimes add custom attributes like:
var DataGrid = Backbone.View.extend({
className:"datagrid",
lookup: {
header: "", //Header wrapper row element
headers: [], //Views in header
body: "", //Body wrapper row element
rows: [] //Views in body
},
events: {
...
},
initialize: function() {
...
},
render: function() {
...
}
});
As you can see I have "lookup" as an extra attribute to the Object. I use DataGrid in a number of my views and I am experiencing a very strange behaviour. When I switch between views that use DataGrid, "lookup" would still be populated with the old data. I use "new" when creating a new DataGrid but I still find old data. Am I missing something?
EDIT: Following #rabs reply. I did a search on static variables in Backbone and found this: Simplify using static class properties in Backbone.js with Coffeescript
I know an answer has been accepted on this (a while ago), but as I came across this question while working on a backbone project recently, I thought it would be worth mentioning that you can define attributes as a function also. This is especially useful for views that need to have attributes set to values in their current models.
By defining attributes as a function you can do something like
var myObject = Backbone.View.extends({
attributes: function() {
if(this.model) {
return {
value: this.model.get('age')
}
}
return {}
}
});
Hope that helps someone
Declaring variables in this way the scope of the variable is to the class not the instance, similar to s static or class variable.
So yeah the lookup object will shared between your different instances.
You could pass the lookup object in to your instance when you create it that way it will behave as an instance variable.

Resources