¿Hipervínculos en el cuadro de texto o en el cuadro de edición de texto?¿Existe alguna forma de insertar un hipervínculo en un cuadro de texto o en un cuadro de edición de texto?Sé que puedes hacer esto en una tabla JMP con el tipo de columna de expresión y que puedes crear un cuadro de botón en una ventana que actúa como un hipervínculo.También conozco la sintaxis de marcado << para cuadros de texto, pero eso solo permite poner negrita, subrayado y cursiva.
Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Enfoque muy genial @ih
Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Combinatorio @Byron_JMP Con la idea de Web Browser Box con su cadena de expresiones regulares, puede guardar un archivo html formateado con enlaces incrustados y mostrarlo en su ventana.De repente tienes mucho control sobre el formato del texto; Incluso podría permitir que los usuarios agreguen opcionalmente un nombre descriptivo a la sintaxis de los enlaces, como [Sitio web de JMP] http://www.jmp.com , similar a alguna sintaxis de marcado.

Names Default To Here( 1 );
text = "Periarthritis is defined as: Inflammation of the tissues around a joint. " ||
"[A Link]http://www.reference.md/files/D010/mD010489.html As arthralgia, myalgia, tendonitis " ||
"and other musculoskeletal issues are listed events, periarthritis can be considered listed as well.
Comment: no good sentinel case — not a new signal; one case also reported somnolence and " ||
"another case reported “yawny” which could mean sleepy *http://www.ncbi.nlm.nih.gov/pubmed/12530994";
t = text;
//wrap links in a string with <A href="https://community.jmp.com/" target="_blank"> tags
findlinks = function({t, recct=0}, {url_regex, rgxmatch = {}, rtn=""},
recct++;
if(recct > 100,
throw("Recursion to deep: " || char(recct) || " levels. Still need to parse: '" || t || "'"));
url_regex = "^(.*?)(\!\[(.+)\])?((https?://){0,}(\w+\.){2,}\w+/?(\w+/?){0,}(\.\w+){0,1}/?)(\b.*)$";
rgxmatch = Regex Match(t, url_regex);
if( N Items(rgxmatch) == 0,
rtn = t, //No link
if( N Items(rgxmatch) == 10, //found a link
rtn = rgxmatch[2] ||
"</A><A href="" || rgxmatch[5] || "" target="_blank" rel="nofollow noopener noreferrer">" || if(is missing(rgxmatch[4]), rgxmatch[5], rgxmatch[4] ) || "</A>" ||
findlinks(rgxmatch[10], recct),
throw("Error matching regex in: '" || t || "'")
)
);
return(rtn)
);
//Create a simple html page from a block of text, save it to the temp files, and return the filename
texttohtmlfile = function({t},
Save text file("$TEMP/Temp HTML file.html", "" || findlinks(t) || "")
);
//Make a temp html file
fn = texttohtmlfile(text);
//Simple window to display html file, deletes the temp file when it closes
w = New Window("Example",wb = Web Browser Box());
w << On Close( Delete File( fn ) );
wb << Set Size(1000, 200);
wb << Set Auto Stretching( 1, 1 );
wb << Set Max Size( 1000, 1000 );
//Show the html file in the window
wb << Navigate( fn );Tenga en cuenta la desafortunada barra diagonal en la expresión de coincidencia de expresiones regulares cuando "\[" comienza una sección de 'carácter de escape'.
Editado para agregar captura de pantalla y nuevamente para corregir un error tipográfico.
Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Gracias por esa sugerencia Marcos.Sin embargo, no quiero que mis usuarios tengan que insertar etiquetas para las URL.A mi jefe se le ocurrió una expresión regular que funciona bastante bien:
// Sample text
text = "Periarthritis is defined as: Inflammation of the tissues around a joint. " ||
"http://www.reference.md/files/D010/mD010489.html As arthralgia, myalgia, tendonitis " ||
"and other musculoskeletal issues are listed events, periarthritis can be considered listed as well.
Comment: no good sentinel case — not a new signal; one case also reported somnolence and " ||
"another case reported “yawny” which could mean sleepy *http://www.ncbi.nlm.nih.gov/pubmed/12530994";
url_regex = "\b(https?://){0,}(\w+\.){2,}\w+/?(\w+/?){0,}(\.\w+){0,1}/?\b";
text_list = {};
link_list = {};
keep_going = 1;
istart = 1;
text_len = length(text);
i = 0;
while(keep_going,
new_text = substr(text, istart);
link_text = regex(new_text, url_regex);
if (!is missing(link_text),
// then
i++;
start_pos = contains(text, link_text, istart);
text_list[i] = substr(text, istart, (start_pos - istart - 1));
link_list[i] = link_text;
istart = start_pos + length(link_text);
,
// else no link found
i++;
text_list[i] = new_text;
keep_going = 0;
);
);
tb = {};
lb = {};
nt = nitems(text_list);
nw = new window("Test link",
vb = vlistbox(
)
);
for(i = 1, i <= nt, i++,
tb[i] = text box(text_list[i], << set width(400));
vb << append(tb[i]);
if (i < nt,
one_button = evalinsert("\[lb[i] = button box("^link_list[i]^", web("^link_list[i]^"), << underline style(1) )]\");
eval(parse(one_button));
vb << append(lb[i]);
);
);
Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Consulte la función Regex(). Podría resultar útil. La expresión regular sería bastante simple.
Names Default to Here( 1 );
text = "Periarthritis is defined as: Inflammation of the tissues around a joint. " ||
"<L>http://www.reference.md/files/D010/mD010489.html</L> As arthralgia, myalgia, tendonitis " ||
"and other musculoskeletal issues are listed events, periarthritis can be considered listed as well.
Comment: no good sentinel case — not a new signal; one case also reported somnolence and " ||
"another case reported “yawny” which could mean sleepy *<L>http://www.ncbi.nlm.nih.gov/pubmed/12530994</L>";
Regex( text,
"<L>(.+?)</L>",
"\1"
);
Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Gracias por sus comentarios y sugerencias hasta ahora.No tengo el lujo de saber dónde están las URL en los comentarios de los usuarios.
Aquí hay algunos resultados de muestra:

Aquí hay un código de muestra.Lo hice fácil usando "marcadores" de URL y .He estado jugando con la ubicación de la URL usando expresiones regulares para evitar tener que usar estos marcadores.Si alguien tiene una buena expresión regular para buscar URL, hágamelo saber.Estoy teniendo distintos éxitos con lo que he encontrado en la red hasta ahora.
// link markup example
text = "Periarthritis is defined as: Inflammation of the tissues around a joint. " ||
"<L>http://www.reference.md/files/D010/mD010489.html</L> As arthralgia, myalgia, tendonitis " ||
"and other musculoskeletal issues are listed events, periarthritis can be considered listed as well.
Comment: no good sentinel case — not a new signal; one case also reported somnolence and " ||
"another case reported “yawny” which could mean sleepy *<L>http://www.ncbi.nlm.nih.gov/pubmed/12530994</L>";
text_list = {};
link_list = {};
keep_going = 1;
istart = 1;
linkstart = "<L>";
linkend = "</L>";
text_len = length(text);
i = 0;
while(keep_going,
start_pos = contains(text, linkstart, istart);
if (start_pos,
end_pos = contains(text, linkend, istart);
if (end_pos,
i++;
text_list[i] = substr(text, istart, (start_pos - istart));
link_list[i] = substr(text, start_pos + 3, (end_pos - start_pos - 3));
istart = istart + end_pos - istart + 4;
);
);
if (!start_pos,
i++;
text_list[i] = substr(text, istart);
keep_going = 0;
);
);
tb = {};
lb = {};
nt = nitems(text_list);
nw = new window("Test link",
vb = vlistbox(
)
);
for(i = 1, i <= nt, i++,
tb[i] = text box(text_list[i], << set width(400));
vb << append(tb[i]);
if (i < nt,
one_button = evalinsert("\[lb[i] = button box("^link_list[i]^", web("^link_list[i]^"), << underline style(1) )]\");
eval(parse(one_button));
vb << append(lb[i]);
);
);
Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Ah, y haga del mousebox(textBox) una función o expresión que se pueda usar muchas veces, donde solo cambie el texto, el enlace encontrado.
Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Esta solución requiere algo extra: un WrapListBox y un MouseBox.
Names Default To Here( 1 );
New Window( "WrapListBox",
Wrap List Box(
TextBox("This is a long comment to be followed by a link "),
MouseBox(TextBox(" <U>http://www.jmp.com</U> ",<<FONT color="">");
web(lnk);
(this<<CHILD></CHILD></FONT>
Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Podría utilizar una expresión regular para que coincida con el patrón de hipervínculo.
Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Creo que podría ser posible analizar el contenido del cuadro de texto para un enlace html (buscar patrones que comiencen con "//:http") y luego agregar un cuadro de botón al cuadro de texto, con el enlace, para cada patrón que se analiza.
Aunque eso será bastante complejo. Sería mucho mejor si los enlaces se reconocieran en el texto y se pudiera hacer clic en ellos.
Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Si está de acuerdo con que todo el cuadro sea el enlace, entonces puede usar un cuadro de botón:
New Window( "Example",
Text box("Text Block 1"),
Button box( "http://www.jmp.com/", Web( "http://www.jmp.com/" ), Underline Style( 1 ) )
)Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Gracias Byron, es un guión genial.Pero no es lo que estaba buscando.Específicamente, quiero incrustar un enlace en un cuadro de texto y que se pueda hacer clic en él.Mis usuarios ingresan comentarios que pueden ser largos y contener enlaces de referencia.Estoy trabajando en un enfoque en el que analizo los enlaces y muestro:
Bloque de texto1 (en un cuadro de texto)
Enlace1 (como un enlace en el que se puede hacer clic)
Bloque de texto2 (en un cuadro de texto)
Enlace2 (como un enlace en el que se puede hacer clic)
Bloque de texto3
etc.
Probablemente esto sea aceptable para los usuarios.
Re: ¿Hipervínculos en cuadro de texto o cuadro de edición de texto?Sospecho que estás buscando algo más sofisticado que esto, pero...
Names Default To Here( 1 );
New Window( "Example",
hlistbox("1",
wb = Web Browser Box(),
bb=Button Box( "Take Me to JMP",
wb << Navigate( "http://www.jmp.com" );
wb << Set Auto Stretching( 1, 1 );
wb << Set Max Size( 1000, 1000 );
)));