From 13456792ad404af17dbae3152b2639f11ffe1d5a Mon Sep 17 00:00:00 2001 From: Sean Yamana Date: Sat, 27 Nov 2021 17:25:43 -0800 Subject: [PATCH] added ignoreClass and processClass tex2jax options (#36) * added ignoreClass and processClass tex2jax options * Nits in options description Co-authored-by: Ellis Michael --- css/options.css | 5 +++++ js/background.js | 16 +++++++++++++--- js/options.js | 2 ++ js/optionsPage.js | 37 ++++++++++++++++++++++++++++++++++++- js/pageScript.js | 4 +++- js/texify.js | 3 ++- manifest.json | 2 +- options.html | 14 ++++++++++++++ 8 files changed, 76 insertions(+), 7 deletions(-) diff --git a/css/options.css b/css/options.css index 62ae99a1..2d4d876d 100644 --- a/css/options.css +++ b/css/options.css @@ -54,3 +54,8 @@ td { width: 2em; margin-left: .5em; } + +.classBox { + width: 20em; + margin-left: .5em; +} diff --git a/js/background.js b/js/background.js index 88cb1efc..c94292b9 100644 --- a/js/background.js +++ b/js/background.js @@ -58,7 +58,9 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { if (request.method == 'shouldTeXify') { sendResponse({answer: should_texify(request.host), delimiters: get_delimiters(), - skip_tags: get_skip_tags()}); + skip_tags: get_skip_tags(), + ignore_class: get_ignore_class(), + process_class: get_process_class()}); } else { sendResponse({}); } @@ -95,10 +97,18 @@ function get_delimiters() { delimiters.inline_custom = get_option('inline_custom') delimiters.display_dollar = get_option('display_dollar'); delimiters.display_bracket = get_option('display_bracket'); - delimiters.display_custom = get_option('display_custom') + delimiters.display_custom = get_option('display_custom'); return delimiters; } function get_skip_tags(){ - return get_option('skip_tags') + return get_option('skip_tags'); +} + +function get_ignore_class(){ + return get_option('ignore_class'); +} + +function get_process_class(){ + return get_option('process_class'); } diff --git a/js/options.js b/js/options.js index be2b6d3b..93285be3 100644 --- a/js/options.js +++ b/js/options.js @@ -8,6 +8,8 @@ var default_options = { display_dollar: true, display_bracket: true, display_custom: false, + ignore_class: false, + process_class: false, skip_tags: ['script','noscript','style','textarea','pre','code'] }; diff --git a/js/optionsPage.js b/js/optionsPage.js index 088abf88..98b7458a 100644 --- a/js/optionsPage.js +++ b/js/optionsPage.js @@ -51,6 +51,27 @@ function save_options() { // White List Mode set_option('white_list_mode', $('#chkWhiteListMode').is(':checked')); + // tex2jax Ignore Class + var ignore_class = $('#ignoreClass').val().trim(); + if (!ignore_class) { + ignore_class = "tex2jax_ignore"; + } + if ($('#chkIgnoreClass').is(':checked') && ignore_class) { + set_option('ignore_class', ignore_class); + } else { + set_option('ignore_class', false); + } + // tex2jax Process Class + var process_class = $('#processClass').val().trim(); + if (!process_class) { + process_class = "tex2jax_process"; + } + if ($('#chkProcessClass').is(':checked') && process_class) { + set_option('process_class', process_class); + } else { + set_option('process_class', false); + } + displayMessage('Options saved.'); } @@ -100,6 +121,20 @@ function restore_options() { text : site })); }); + + // tex2jax Ignore Class + var ignore_class = get_option('ignore_class'); + if(ignore_class) { + $('#chkIgnoreClass').prop('checked', true); + $('#ignoreClass').val(ignore_class); + } + + // tex2jax Process Class + var process_class = get_option('process_class'); + if(process_class) { + $('#chkProcessClass').prop('checked', true); + $('#processClass').val(process_class); + } // White List Mode if (get_option('white_list_mode')) { @@ -149,7 +184,7 @@ function clear_tags() { function restore_default_tags() { var default_tags = get_default_option('skip_tags'); - clear_tags() + clear_tags(); $.each(default_tags, function(index, tag) { $('#selTag').append($('