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

Added methods setSource to Block, Cell and ListItem #523

Merged

Conversation

robertpanzer
Copy link
Member

This PR tackles points 2 & 3 of #513

It adds the method setSource(String) to Block, ListItem and Cell.
There's also a new method Block.setLines(List<String>) to set the source lines.

@robertpanzer robertpanzer merged commit f7fcb42 into asciidoctor:asciidoctorj-1.6.0 Oct 18, 2016
@robertpanzer robertpanzer deleted the set-source branch October 18, 2016 05:30
@jiangrij
Copy link

Hi robertpanzer,
I tried to use setSource(String) to a Cell, but it does not work for generating HTML(the cell source was not updated). Is there anything else I missed? Could you please advise?

The following is the code which extends from Treeprocessor:
----------------- code part ---------------------
public Document process(Document document) {
List blockslist1 = document.getBlocks();
.......
List blockslist = section.getBlocks();
for (StructuralNode abstractBlock : blockslist) {
if ((abstractBlock instanceof Table)) {
Table table = (Table) abstractBlock;
for (Row row : table.getBody()) {
List cells = row.getCells();
for (int cellindex = 0; cellindex < cells.size(); cellindex++) {
Cell cell = cells.get(cellindex);
cell.setSource("New Source");

Thanks.

@robertpanzer
Copy link
Member Author

It looks like we're missing a method setText() at the moment.
For now you will have to create a new Cell with Processor.createTableCell(column, "New Source") and replace it in the cells.

@robertpanzer
Copy link
Member Author

I just tried an example like this and it worked for me.
Are you sure that the your conditions found the table?

@robertpanzer
Copy link
Member Author

@jiangrij I just added a test in #638 that shows that updating the source of a cell works.

robertpanzer added a commit that referenced this pull request Mar 25, 2018
#523 Add explicit test for updating table cell source
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants