Skip to content

Mejoras y correcciones #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6816224
Setting para edición en WSL y revisión de la introducción.
ckdvk Feb 6, 2025
f59d70b
Update README.md
ckdvk Feb 6, 2025
1d0754c
Capítulo 1 revisado.
ckdvk Feb 7, 2025
955391e
.
ckdvk Feb 7, 2025
44bde52
Merge branch 'main' of https://github.com/ckdvk/eloquent-javascript-es
ckdvk Feb 7, 2025
baf7972
Cambiado "control de flujo" por "flujo de control". revisado y correg…
ckdvk Feb 8, 2025
44f4216
aclaración añadida en capítulo 2. Añadida funcinoalidad de notas (par…
ckdvk Feb 9, 2025
11a287c
Actualización del capítulo 2. Capítulo 3 revisado. Funcionalidad de a…
ckdvk Feb 9, 2025
e961d97
pequeña corrección
ckdvk Feb 9, 2025
aad2c2b
modificaciones en el código para función de notas
ckdvk Feb 9, 2025
14ccca7
otro fix para las notas
ckdvk Feb 9, 2025
cb8d4a3
último fix. Había fallos en los commits
ckdvk Feb 9, 2025
6ed4bb5
pequeña revisión del capítulo 2, sobre el uso de enlace, asociación o…
ckdvk Feb 9, 2025
563a074
revisado capítulo 4. Algún ajuste en capítulo 2. TODO: Revisar ejerci…
ckdvk Feb 11, 2025
0696b65
revisiones de las traducciones de ejercicios hasta el capítulo 4. Aña…
ckdvk Feb 12, 2025
7a416a1
Revisado cap. 5. tener cuidado a la hora de escribir cosas como _((ab…
ckdvk Feb 12, 2025
3fc061a
revisado capítulo 6 a falta de resumen y ejercicios
ckdvk Feb 13, 2025
059f9a2
revisados ejercicios capítulo 6
ckdvk Feb 13, 2025
91f1e29
revisado capítulo 7
ckdvk Feb 13, 2025
325812e
capitulo 8 revisado
ckdvk Feb 15, 2025
9d7353f
revisado capítulo 9. Corregidas las apariciones de caracter sin tilde
ckdvk Feb 16, 2025
a319e3c
revisado capítulo 10. Pequeños cambios en capítulo 9
ckdvk Feb 16, 2025
af767e4
revisado capítulo 11. Retocados algunas traducciones de otros capítul…
ckdvk Feb 18, 2025
65f13ce
revisado capítulo 12. Alguna corrección en 5 y 11
ckdvk Feb 20, 2025
c27f019
revisado capítulo 13
ckdvk Feb 20, 2025
de94cf1
revisado el capítulo 14
ckdvk Feb 21, 2025
6ec828c
revisado capítulo 15
ckdvk Feb 22, 2025
68c5161
revisado capítulo 16. Cambiado nombre de los capítulos de proyecto en…
ckdvk Feb 22, 2025
0f52b1a
revisado capítulo 17. Arreglado problema del anterior commit al cambi…
ckdvk Feb 22, 2025
8463c6f
Revisado capítulo 18. Supongo que el código que debe mostrar un 405 l…
ckdvk Feb 23, 2025
22b42b0
revisado capítulo 19. Arreglado problema previo a la sección guardar …
ckdvk Feb 23, 2025
2c2da33
revisado capítulo 20. Modificado el código para que no sea interactiv…
ckdvk Feb 23, 2025
9d8f409
revisado el capítulo 21. Corregido problema con el código en el capít…
ckdvk Feb 23, 2025
05d6a62
modificaciones para añadir las notas a pie de página en LaTeX correct…
ckdvk Feb 23, 2025
8da1659
traducido texto introductorio de las pistas. Añadido mi nombre en la …
ckdvk Feb 23, 2025
9061eb5
cover update (with improvements). No working references fixed
ckdvk Feb 24, 2025
322ea83
Update README.md with new cover
ckdvk Feb 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 53 additions & 51 deletions 00_intro.md

Large diffs are not rendered by default.

120 changes: 63 additions & 57 deletions 01_values.md

Large diffs are not rendered by default.

210 changes: 106 additions & 104 deletions 02_program_structure.md

Large diffs are not rendered by default.

343 changes: 177 additions & 166 deletions 03_functions.md

Large diffs are not rendered by default.

504 changes: 258 additions & 246 deletions 04_data.md

Large diffs are not rendered by default.

322 changes: 167 additions & 155 deletions 05_higher_order.md

Large diffs are not rendered by default.

448 changes: 225 additions & 223 deletions 06_object.md

Large diffs are not rendered by default.

82 changes: 41 additions & 41 deletions 07_robot.md

Large diffs are not rendered by default.

266 changes: 135 additions & 131 deletions 08_error.md

Large diffs are not rendered by default.

281 changes: 142 additions & 139 deletions 09_regexp.md

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions 10_modules.md

Large diffs are not rendered by default.

430 changes: 221 additions & 209 deletions 11_async.md

Large diffs are not rendered by default.

91 changes: 47 additions & 44 deletions 12_language.md

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions 13_browser.md

Large diffs are not rendered by default.

263 changes: 134 additions & 129 deletions 14_dom.md

Large diffs are not rendered by default.

252 changes: 126 additions & 126 deletions 15_event.md

Large diffs are not rendered by default.

148 changes: 75 additions & 73 deletions 16_game.md

Large diffs are not rendered by default.

142 changes: 72 additions & 70 deletions 17_canvas.md

Large diffs are not rendered by default.

272 changes: 141 additions & 131 deletions 18_http.md

Large diffs are not rendered by default.

138 changes: 84 additions & 54 deletions 19_paint.md

Large diffs are not rendered by default.

171 changes: 90 additions & 81 deletions 20_node.md

Large diffs are not rendered by default.

137 changes: 72 additions & 65 deletions 21_skillsharing.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Eloquent JavaScript en Español

<a href='https://midu.link/eloquent'>
<img alt="Portada del libro" src="https://github.com/midudev/eloquent-javascript-es/assets/1561955/727c8b2a-0a0f-4e9b-a6e1-9c1ec5765612" width="250px" />
<img alt="Portada del libro" src="./img/cover.jpg" width="250px" />
</a>

Traducción de la cuarta edición de [Eloquent JavaScript](https://eloquentjavascript.net/) al español por [midudev](https://twitch.tv/midudev).
Traducción de la cuarta edición de [Eloquent JavaScript](https://eloquentjavascript.net/) al español por [midudev](https://twitch.tv/midudev). Modificaciones por [ckdvk](https://github.com/ckdvk) para una lectura más natural.

[Repositorio original](https://github.com/marijnh/Eloquent-JavaScript)

Expand Down Expand Up @@ -49,4 +49,4 @@ Traducción de la cuarta edición de [Eloquent JavaScript](https://eloquentjavas
Avallone. Fotografía del pueblo en el Capítulo 11 por Fabrice Creuzot. Concepto de juego para el Capítulo 16
por <a href="http://lessmilk.com">Thomas
Palef</a>.</p>
</div>
</div>
Binary file modified book.epub
Binary file not shown.
Binary file modified book.mobi
Binary file not shown.
Binary file modified book.pdf
Binary file not shown.
Binary file modified book_mobile.pdf
Binary file not shown.
6 changes: 3 additions & 3 deletions code/hangar2.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ var readTextFile = function() {

let files = {
__proto__: null,
"shopping_list.txt": "Peanut butter\nBananas",
"lista_compra.txt": "Mantequilla de cacahuete\nPlátanos",
"old_shopping_list.txt": "Peanut butter\nJelly",
"package.json": '{"name":"test project","author":"cāāw-krö","version":"1.1.2"}',
"plans.txt": "* Write a book\n * Figure out asynchronous chapter\n * Find an artist for the cover\n * Write the rest of the book\n\n* Don't be sad\n * Sit under tree\n * Study bugs\n",
"planes.txt": "* Escribir un libro\n * Escribir el capítulo sobre programación asíncrona\n * Encontrar un artista para la portada\n * Escribir el resto del libro\n\n* No estar triste\n * Sentarme bajo un árbol\n * Estudiar bichos\n",
"camera_logs.txt": logs.map(l => l.name).join("\n")
}

Expand Down Expand Up @@ -174,7 +174,7 @@ var request = function(){
}
}()

var clipImages = [
var imágenesVídeo = [
[
" 5dc",
" e9.2 2b.3 .3 2b.o.3o. 2b.o.3o. 27.2 2.o2.o2. 27.o. .Oo.oO. . 25.o. .Oo.oO.4 20.2 2.Oo .Oo.oO.2o. 20.o 2.Oo.2Oo.oO.2o. 20.O. .O2.2Oo2O2o3. 20.O2 2oOo.O2oO2o3. 20.oOo oO2oO2oO2oOo. 1e.o2O3o2O8oOo 1f.O6oOao 1e.oO11o 1eoO12o. 1c.O13o. 6. 14.O14o. 1boO15. 1bO15o. 1aoO15o 1a.O16. 18. .O15o 1boO15. 1a.O15o 1b.O15. f",
Expand Down
18 changes: 9 additions & 9 deletions code/packages_chapter_10.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ module.exports = {
pm: 'PM'
};`)

require.preload("./dayname.js", String.raw`
const names = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"];
require.preload("./nombredia.js", String.raw`
const nombres = ["Domingo", "Lunes", "Martes", "Miércoles",
"Jueves", "Viernes", "Sábado"];

exports.dayName = function(number) {
return names[number];
exports.nombreDía = function(número) {
return nombres[número];
}
exports.dayNumber = function(name) {
return names.indexOf(name);
exports.númeroDía = function(nombre) {
return nombres.indexOf(nombre);
}`)

require.preload("./seasonname.js", String.raw`
module.exports = ["Winter", "Spring", "Summer", "Autumn"];`)
require.preload("./nombresestaciones.js", String.raw`
module.exports = ["Invierno", "Primavera", "Verano", "Otoño"];`)

/* ini 1.3.5: https://github.com/npm/ini

Expand Down
17 changes: 17 additions & 0 deletions epub/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,20 @@ ol li p {
.cm-atom {color: #219;}
.cm-number {color: #164;}
.cm-def {color: #00f;}


.translator-note {
background-color: #f8f9fa;
border-left: 4px solid #e9da0875;
padding: 0px 12px;
font-size: medium;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
word-spacing: 0.2em;
margin: 10px 0;
font-style: italic;
}
.translator-note code {
font-size: inherit;
font-family: 'Courier New', Courier, monospace;
background-color: #f1f1f100;
}
106 changes: 54 additions & 52 deletions html/00_intro.html

Large diffs are not rendered by default.

122 changes: 64 additions & 58 deletions html/01_values.html

Large diffs are not rendered by default.

217 changes: 110 additions & 107 deletions html/02_program_structure.html

Large diffs are not rendered by default.

344 changes: 177 additions & 167 deletions html/03_functions.html

Large diffs are not rendered by default.

501 changes: 258 additions & 243 deletions html/04_data.html

Large diffs are not rendered by default.

329 changes: 171 additions & 158 deletions html/05_higher_order.html

Large diffs are not rendered by default.

453 changes: 228 additions & 225 deletions html/06_object.html

Large diffs are not rendered by default.

80 changes: 40 additions & 40 deletions html/07_robot.html

Large diffs are not rendered by default.

274 changes: 139 additions & 135 deletions html/08_error.html

Large diffs are not rendered by default.

285 changes: 144 additions & 141 deletions html/09_regexp.html

Large diffs are not rendered by default.

138 changes: 69 additions & 69 deletions html/10_modules.html

Large diffs are not rendered by default.

424 changes: 218 additions & 206 deletions html/11_async.html

Large diffs are not rendered by default.

94 changes: 48 additions & 46 deletions html/12_language.html

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions html/13_browser.html

Large diffs are not rendered by default.

276 changes: 141 additions & 135 deletions html/14_dom.html

Large diffs are not rendered by default.

280 changes: 140 additions & 140 deletions html/15_event.html

Large diffs are not rendered by default.

149 changes: 75 additions & 74 deletions html/16_game.html

Large diffs are not rendered by default.

138 changes: 70 additions & 68 deletions html/17_canvas.html

Large diffs are not rendered by default.

288 changes: 149 additions & 139 deletions html/18_http.html

Large diffs are not rendered by default.

134 changes: 78 additions & 56 deletions html/19_paint.html

Large diffs are not rendered by default.

341 changes: 175 additions & 166 deletions html/20_node.html

Large diffs are not rendered by default.

520 changes: 263 additions & 257 deletions html/21_skillsharing.html

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions html/css/ejs.css
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,21 @@ sub {
sup {
font-size: 70%;
}


.translator-note {
background-color: #f8f9fa;
border-left: 4px solid #e9da0875;
padding: 0px 12px;
font-size: medium;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
word-spacing: 0.2em;
margin: 10px 0;
font-style: italic;
}
.translator-note code {
font-size: inherit;
font-family: 'Courier New', Courier, monospace;
background-color: #f1f1f100;
}

2 changes: 1 addition & 1 deletion html/ejs.js

Large diffs are not rendered by default.

Binary file modified img/cover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@rollup/plugin-terser": "^0.4.4",
"acorn": "^8.0.0",
"acorn-walk": "^8.0.0",
"chokidar-cli": "^3.0.0",
"codemirror": "^6.0.0",
"jszip": "^3.10.0",
"markdown-it": "^14.0.0",
Expand Down
2 changes: 1 addition & 1 deletion pdf/book.tex
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@

Las ilustraciones son contribuciones de varios artistas: Portada por Péchane Sumi-e. Ilustraciones de capítulos por Madalina Tantareanu. Arte de píxeles en los capítulos 7 y 16 por Antonio Perdomo Pastor. Diagramas de expresiones regulares en el capítulo 9 generados con \href{http://regexper.com}{regexper.com} por Jeff Avallone. Fotografía del pueblo en el capítulo 11 por Fabrice Creuzot. Concepto de juego para el capítulo 16 por \href{http://lessmilk.com}{Thomas Palef}.

Traducción al español por \href{http://twitch.tv/midudev}{midudev}.
Traducción al español por \href{http://twitch.tv/midudev}{midudev} y \href{https://github.com/ckdvk}{ckdvk}.

\vskip 1em

Expand Down
10 changes: 5 additions & 5 deletions src/chapter_info.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const TRANSLATIONS_MAP = {
'02_3_tablero_de_ajedrez.js': '02_3_chessboard.js',
'03_1_mnimo.js': '03_1_minimum.js',
'03_2_recursin.js': '03_2_recursion.js',
'03_3_contando_frijoles.js': '03_3_bean_counting.js',
'04_1_la_suma_de_un_rango.js': '04_1_the_sum_of_a_range.js',
'04_2_reversin_de_un_array.js': '04_2_reversing_an_array.js',
'03_3_contando_minuciosamente.js': '03_3_bean_counting.js',
'04_1_la_suma_de_un_intervalo.js': '04_1_the_sum_of_a_range.js',
'04_2_dando_la_vuelta_a_un_array.js': '04_2_reversing_an_array.js',
'04_3_lista.js': '04_3_a_list.js',
'04_4_comparacin_profunda.js': '04_4_deep_comparison.js',
'05_1_aplanamiento.js': '05_1_flattening.js',
'05_2_tu_propio_bucle.js': '05_2_your_own_loop.js',
'05_4_direccin_de_escritura_dominante.js': '05_4_dominant_writing_direction.js',
'06_1_un_tipo_de_vector.js': '06_1_a_vector_type.js',
'06_1_un_tipo_vector.js': '06_1_a_vector_type.js',
'06_2_grupos.js': '06_2_groups.js',
'06_3_grupos_iterables.js': '06_3_iterable_groups.js',
'07_1_medicin_de_un_robot.js': '07_1_measuring_a_robot.js',
Expand All @@ -42,7 +42,7 @@ const TRANSLATIONS_MAP = {
'15_1_globo.html': '15_1_balloon.html',
'15_2_estela_del_ratn.html': '15_2_mouse_trail.html',
'15_3_pestaas.html': '15_3_tabs.html',
'16_1_juego_terminado.html': '16_1_game_over.html',
'16_1_fin_del_juego.html': '16_1_game_over.html',
'16_2_pausar_el_juego.html': '16_2_pausing_the_game.html',
'16_3_un_monstruo.html': '16_3_a_monster.html',
'17_1_formas.html': '17_1_shapes.html',
Expand Down
2 changes: 1 addition & 1 deletion src/extract_hints.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {readdirSync, readFileSync} from "fs"

process.stdout.write("# Exercise Hints\n\nThe hints below might help when you are stuck with one of the exercises in this book. They don't give away the entire solution, but rather try to help you find it yourself.\n\n");
process.stdout.write("# Pistas para los Ejercicios\n\nLas pistas a continuación pueden ayudarte cuando te encuentres atascado con uno de los ejercicios de este libro. No revelan la solución completa, sino que intentan ayudarte a encontrarla tú mismo.\n\n");

for (let name of readdirSync(".")) {
if (!/^\d\d.*\.md$/.test(name)) continue
Expand Down
28 changes: 28 additions & 0 deletions src/markdown.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,33 @@ function parseIndexTerm(state, silent) {
return true
}

function parseBlockNote(state, startLine, endLine) {
let pos = state.bMarks[startLine] + state.tShift[startLine];
let max = state.eMarks[startLine];

if (state.src.slice(pos, pos + 7) !== ':::note') return false;

let contentStart = pos + 7;
let contentEnd = max;
let close = state.src.indexOf(':::', contentStart);
if (close === -1) return false;

contentEnd = close;

let content = state.src.slice(contentStart, contentEnd).trim();

let htmlContent = state.md.render(content);

let token = state.push('meta_note_open', '', 1);
token.map = [startLine, startLine + 1];
token.content = htmlContent;

state.push('meta_note_close', '', -1);

state.line = startLine + 1;
return true;
}

let TERMINATOR_RE = /[\n!#$%&*+\-:<=>@\[\\\]^_`{}~]|\(\(/

function newText(state, silent) {
Expand All @@ -171,6 +198,7 @@ function plugin(md) {
md.block.ruler.before("code", "meta", parseBlockMeta)
md.block.ruler.before("code", "table", parseBlockTable)
md.inline.ruler.before("link", "meta", parseInlineMeta)
md.block.ruler.before("code", "note", parseBlockNote)
md.inline.ruler.at("text", newText)
md.inline.ruler.before("strikethrough", "index_term", parseIndexTerm)
}
Expand Down
29 changes: 28 additions & 1 deletion src/render_html.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,34 @@ for (const arg of process.argv.slice(2)) {
if (!file) throw new Error('No input file')
const chapter = /^\d{2}_([^\.]+)/.exec(file) || [null, 'hints']

















const { tokens, metadata } = transformTokens(markdown.parse(fs.readFileSync(file, 'utf8'), {}), {
defined: epub ? ['book', 'html'] : ['interactive', 'html'],
strip: epub ? 'hints' : '',
takeTitle: true,
index: false
})






const close = epub ? '/' : ''
const dir = dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -172,6 +193,11 @@ const renderer = {
return `<figure${attrs(token)}${className ? ` class="${className}"` : ''}><img src="${escape(url)}" alt="${escape(alt)}"${close}></figure>`
},

meta_note(token) {
return `\n\n<div class="translator-note">${markdown.render(token.args[0])}</div>`;
},


meta_quote_open () { return '\n\n<blockquote>' },
meta_quote_close (token) {
const { author, title } = token.args[0] || {}
Expand All @@ -182,7 +208,8 @@ const renderer = {
meta_keyname_close () { return '</span>' },

meta_hint_open () { return '\n\n<details class="solution"><summary>Mostrar pistas...</summary><div class="solution-text">' },
meta_hint_close () { return '\n\n</div></details>' }
meta_hint_close () { return '\n\n</div></details>' },

}

function renderArray (tokens) {
Expand Down
29 changes: 29 additions & 0 deletions src/render_latex.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,35 @@ const renderer = {
meta_keyname_open () { return noStarch ? '\\keycap{' : '\\textsc{' },
meta_keyname_close () { return '}' },

meta_note(token) {
let contenido = '';
if (token.children && token.children.length) {
contenido = renderArray(token.children);
} else if (token.args && token.args[0]) {
contenido = renderArray(markdown.parse(token.args[0], {}));
}


const escapeLatex = str => str
.replace(/\\/g, '\\textbackslash{}') // Escapar \ como \textbackslash{}
.replace(/_/g, '\\_') // Escapar _ como \_
.replace(/\^/g, '\\textasciicircum{}') // Escapar ^ como \textasciicircum{}
.replace(/~/g, '\\textasciitilde{}') // Escapar ~ como \textasciitilde{}
.replace(/#/g, '\\#') // Escapar #
.replace(/%/g, '\\%') // Escapar %
.replace(/&/g, '\\&') // Escapar &
.replace(/{/g, '\\{') // Escapar {
.replace(/}/g, '\\}'); // Escapar }

// Reemplazo correcto para \lstinline
contenido = contenido.replace(/\\lstinline`([^`]+)`/g, (_, code) => `\\texttt{${escapeLatex(code)}}`);


// contenido = contenido.replace(/\\lstinline\`([^`]+)\`/g, '\\texttt{\\$1}');

return contenido ? `\\footnote{${contenido}}` : '';
},

link_open (token) {
const href = token.attrGet('href')
const maybeChapter = /^(\w+)(?:#(.*))?$/.exec(href)
Expand Down
Loading