Skip to content
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

[proposal] Enable external renderers to render binary files #7614

Closed
2 of 7 tasks
HarvsG opened this issue Jul 25, 2019 · 2 comments
Closed
2 of 7 tasks

[proposal] Enable external renderers to render binary files #7614

HarvsG opened this issue Jul 25, 2019 · 2 comments
Labels
type/enhancement An improvement of existing functionality
Milestone

Comments

@HarvsG
Copy link
Contributor

HarvsG commented Jul 25, 2019

  • Gitea version (or commit ref): 1.8.2
  • Git version: 2.17.1
  • Operating system: Ubuntu 18.04
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

After having success with jupyter notebooks and nbconvert, I wanted to try pandoc. So I installed pandoc and added the below to my app.ini:

[markup.word]
ENABLED = true
FILE_EXTENSIONS = .docx
RENDER_COMMAND = "pandoc -f docx -t html "
IS_INPUT_FILE = true

I have tested on the machine to ensure that pandoc is correctly configured and when I run pandoc -f docx -t html test.docx I get html output. However if I navigate to the repo I just get the 'view raw' hyperlink

I have also tested pandoc on other file types and it appears to be working - or at least doing something. With this it is like the command is not being called at all. Could it be because the file is labelled as a binary and so never even beings to render?
...

Looks as if it might be related to/a duplicate of #4996

Edit & Proposal

As per my entry in #4996
I propose the following untested addition in order to allow external renderers to render binary files if specified by the user

	default:
		if blob.Size() >= setting.UI.MaxDisplayFileSize {
			ctx.Data["IsFileTooLarge"] = true
			break
		}

		d, _ := ioutil.ReadAll(dataRc)
		buf = templates.ToUTF8WithFallback(append(buf, d...))
		if markup.Type(blob.Name()) != "" {
			ctx.Data["IsMarkup"] = true // or ctx.Data["IsRenderedHTML"] = true
			ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
		}

at line

@HarvsG HarvsG changed the title External Renderer pandoc and docx not working [proposal] Enable external renderers to render binary files Jul 25, 2019
@lunny lunny added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Jul 29, 2019
zeripath pushed a commit that referenced this issue Oct 21, 2019
* allow external rendering of other filetypes

fixes #4996 and #7614 
allows rendering of non-tex files, or otherwise accounted for filetypes

* Moves flie-size check before read()

And performs gofmt -s

* Only reads if markType is detected
@davidsvantesson
Copy link
Contributor

This issue is only about rendring from binary files, not to binary files? If so it is implemented by #8300 and can be closed?

It would be cool to also support rendering to binary files (mainly images), but that is maybe another issue.

@lafriks
Copy link
Member

lafriks commented Jan 3, 2020

Closing as implemented, reopen if anything else is needed

@lafriks lafriks closed this as completed Jan 3, 2020
@lafriks lafriks added type/enhancement An improvement of existing functionality and removed type/proposal The new feature has not been accepted yet but needs to be discussed first. labels Jan 3, 2020
@lafriks lafriks added this to the 1.11.0 milestone Jan 3, 2020
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/enhancement An improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

4 participants