rstudio / bookdown

Authoring Books and Technical Documents with R Markdown
https://pkgs.rstudio.com/bookdown/
GNU General Public License v3.0
3.76k stars 1.27k forks source link

Markdown Cross Reference links work in gitbook but NOT in ePub book #1399

Closed tstratopoulos closed 1 year ago

tstratopoulos commented 1 year ago

I am writing a book using markdown and I have been using cross reference links to other chapters, figures, sections, etc. All the cross reference links work fine in the gitbook version, but they do NOT work with the ePub_book. In the ePub version all links redirect to the beginning of each chapter. Interestingly, links to citations work fine on both versions. I have reviewed/replaced the links multiple times and I can't find anything wrong. I have been searching the web and been reading available manuals and I have not been able to find a solution to this problem. I have looked carefully for error messages and there is nothing that I can see. My R/Rstudio/packages are all updated.

I have posted my question on StackOverflow but I did not get answers. I submitted my question to the RStudio community and the suggestion that I received was to create a minimal example and open an issue.

You can access my minimal example (a couple of chapters) from the following dropbox link: minimalExample

Thanks!

TCS

cderv commented 1 year ago

Thanks for the example. I'll have a look.

Is this related somehow to #766 maybe ? It seems we have (or Pandoc) issues with some links

tstratopoulos commented 1 year ago

Thanks for the suggestion. To be honest, I'm not 100% clear about the issue reported in #766. In any case, I noticed that they have some error messages. In my case I don't seem to have any error messages when I look at my log file.

cderv commented 1 year ago

They have error message when they run epubcheck on their file.

If you have not done it, you could try and probably get similar error.

Anyway, I need to find time to get to the bottom of it, and try fix this. Not sure if it is us or pandoc.

Thanks!

jasonmosborne commented 1 year ago

I wrote about this issue and the solution to it in the RStudio community on 09/21/22 (see link below):

https://community.rstudio.com/t/issue-bookdown-epub-book-renders-epub-that-fails-epubcheck-v-4-2-6-with-error-rsc-012-and-error-rsc-005/147973

Not sure if this error has been resolved in the latest bookdown?

jasonmosborne commented 1 year ago

Hi,

You referenced the first post in the chain from 2022-09-21, but there were several more comments.

cderv came back with a reply eventually 2022-09-23, but while I was waiting I kept working the issue.

Below cdervs comment is my solution of 2022-09-23 (part of the solution excerpted below), which is to essentially give make

have the same id as the href name. I had to edit the epub file directly so that every reference in my document had the id as the href name. It was time consuming and annoying.

[image: Screen Shot 2023-03-16 at 10.07.57 PM.png]

cderv's final comment before the issue was closed on 2022-10-05

[image: Screen Shot 2023-03-16 at 10.16.18 PM.png]

so they are aware of the issue and the fix.

I was surprised given this knowledge that they kept referring you back to Issue #766 since the issue and solution I believe they are aware of happened before you posted your Issue #1399.

So I believe, if I am not mistaken, that my simple solution fixes Issue

766 and your Issue #1399.

Best,

Jason

On Thu, Mar 16, 2023 at 3:59 PM tstratopoulos @.***> wrote:

The problem that I have posted resembles your Error[RSC-012]. In your RStudio post you mention that "I do not have a resolution to this epubcheck Error[RSC-012]." Am I missing something?

tstratopoulos commented 1 year ago

Hi Jason - I took down my earlier comment when I realized that I had not reviewed the entire thread.

I have used your suggestions to remove out.width from figures, resolving the first error message (RSC-005). Same as you, I have no way of adjusting the size of the figures.

I have read your instructions on how to deal with the second error message (RSC-012) and I'm having a hard time implementing your suggestion. For starters, I don't know how you access the files that make the ePub file (e.g., where did you find the file content.opf?). In your post, you say that "... Since I understand the problem and fix then the solution will be a simple "find and replace" on the chapter .xhtml files." But I don't know where to find these .xhtml files.

Thanks Theo

jasonmosborne commented 1 year ago

If you open an epub in a text editor like eMacs or aquamacs then you will see the contents of the epub as a collection of files ( many are .xhtml ( one xhtml per document page), image files, etc). Right click the epub file in your documents view then open in a text editor. To my understanding an .epub is a container document type which collects and organizes all the files needed to make the document go.

I was surprised and intrigued to be able to view an epub in this fashion.

It really was time consuming to go page by page (one xhtml file at a time) to fix the referencing, which is why I really hope the folks behind bookdown enact the fix that I believe I have identified.

In the meantime I have been using Adobe Indesign to create my epubs as their epub conversion has passed epubchecker and therefore meets the epub standards.

Best. Jason.

On Fri, Mar 17, 2023 at 12:10 AM TCS @.***> wrote:

Hi Jason - I took down my earlier comment when I realized that I had not reviewed the entire thread.

I have used your suggestions to remove out.width from figures, resolving the first error message (RSC-005). Same as you, I have no way of adjusting the size of the figures.

I have read your instructions on how to deal with the second error message (RSC-012) and I'm having a hard time implementing your suggestion. For starters, I don't know how you access the files that make the ePub file (e.g., where did you find the file content.opf?). In your post, you say that "... Since I understand the problem and fix then the solution will be a simple "find and replace" on the chapter .xhtml files." But I don't know where to find these .xhtml files.

Thanks Theo

— Reply to this email directly, view it on GitHub https://github.com/rstudio/bookdown/issues/1399#issuecomment-1473100762, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6OGFGVEAXDPICEKDY5VWH3W4PP4XANCNFSM6AAAAAATUHEVT4 . You are receiving this because you commented.Message ID: @.***>

-- Sent from Gmail Mobile

tstratopoulos commented 1 year ago

Thanks, Jason! I am hoping that your changes will be implemented. They will certainly save a lot of time. Trying to do this manually takes forever. Unfortunately, given the nature of my text (analysis of data using R) I don't think that I can use inDesign. Theo

jasonmosborne commented 1 year ago

I understand. I too am dependent on a lot of features of RMarkdown and bookdown. I am glad I could help identify the source of the problem which might help with the ultimate fix.

On Sun, Mar 19, 2023 at 4:54 PM TCS @.***> wrote:

Thanks, Jason! I am hoping that your changes will be implemented. They will certainly save a lot of time. Trying to do this manually takes forever. Unfortunately, given the nature of my text (analysis of data using R) I don't think that I can use inDesign. Theo

— Reply to this email directly, view it on GitHub https://github.com/rstudio/bookdown/issues/1399#issuecomment-1475394055, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6OGFGXBSCL4NO36FM5L75LW45XBNANCNFSM6AAAAAATUHEVT4 . You are receiving this because you commented.Message ID: @.***>

-- Sent from Gmail Mobile

cderv commented 1 year ago

Duplicate of #766

cderv commented 1 year ago

Closing in favor of #766 where I commented https://github.com/rstudio/bookdown/issues/766#issuecomment-1534570979

This is indeed the same issue and thanks to you all I have now identified in our processing what is happening.

github-actions[bot] commented 11 months ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.